@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
|
@@ -68,8 +68,16 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
|
|
|
68
68
|
}
|
|
69
69
|
const normalized = this._normalizeConfig(config);
|
|
70
70
|
const options = (factoryArgs[0] ?? {});
|
|
71
|
+
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
72
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
|
|
73
|
+
if (!localNodeId) {
|
|
74
|
+
throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
|
|
75
|
+
}
|
|
71
76
|
const channelName = normalized.channelName ?? DEFAULT_CHANNEL;
|
|
72
77
|
const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
|
|
78
|
+
const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
|
|
79
|
+
const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
|
|
80
|
+
const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
|
|
73
81
|
const baseConfig = {
|
|
74
82
|
drainTimeout: normalized.drainTimeout,
|
|
75
83
|
flowControl: normalized.flowControl,
|
|
@@ -84,6 +92,8 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
|
|
|
84
92
|
type: inpage_connector_js_1.INPAGE_CONNECTOR_TYPE,
|
|
85
93
|
channelName,
|
|
86
94
|
inboxCapacity,
|
|
95
|
+
localNodeId,
|
|
96
|
+
initialTargetNodeId: resolvedTarget,
|
|
87
97
|
};
|
|
88
98
|
const connector = new inpage_connector_js_1.InPageConnector(connectorConfig, baseConfig);
|
|
89
99
|
if (options.authorization) {
|
|
@@ -119,6 +129,16 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
|
|
|
119
129
|
capacity > 0) {
|
|
120
130
|
normalized.inboxCapacity = Math.floor(capacity);
|
|
121
131
|
}
|
|
132
|
+
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
133
|
+
const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
|
|
134
|
+
if (normalizedLocalNodeId) {
|
|
135
|
+
normalized.localNodeId = normalizedLocalNodeId;
|
|
136
|
+
}
|
|
137
|
+
const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
|
|
138
|
+
const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
|
|
139
|
+
if (normalizedTarget) {
|
|
140
|
+
normalized.initialTargetNodeId = normalizedTarget;
|
|
141
|
+
}
|
|
122
142
|
if (typeof candidate.flowControl === 'boolean') {
|
|
123
143
|
normalized.flowControl = candidate.flowControl;
|
|
124
144
|
}
|
|
@@ -157,6 +177,22 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
|
|
|
157
177
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
|
|
158
178
|
return normalized;
|
|
159
179
|
}
|
|
180
|
+
_normalizeNodeId(value) {
|
|
181
|
+
if (typeof value !== 'string') {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const trimmed = value.trim();
|
|
185
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
186
|
+
}
|
|
187
|
+
_normalizeTargetNodeId(value) {
|
|
188
|
+
if (value === undefined || value === null) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
if (value === '*') {
|
|
192
|
+
return '*';
|
|
193
|
+
}
|
|
194
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
195
|
+
}
|
|
160
196
|
}
|
|
161
197
|
exports.InPageConnectorFactory = InPageConnectorFactory;
|
|
162
198
|
exports.default = InPageConnectorFactory;
|
|
@@ -64,6 +64,26 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
64
64
|
}
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
|
+
static normalizeNodeId(value) {
|
|
68
|
+
if (typeof value !== 'string') {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const trimmed = value.trim();
|
|
72
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
73
|
+
}
|
|
74
|
+
static normalizeTargetNodeId(value) {
|
|
75
|
+
if (typeof value !== 'string') {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const trimmed = value.trim();
|
|
79
|
+
if (trimmed.length === 0) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (trimmed === '*') {
|
|
83
|
+
return '*';
|
|
84
|
+
}
|
|
85
|
+
return trimmed;
|
|
86
|
+
}
|
|
67
87
|
constructor(config, baseConfig = {}) {
|
|
68
88
|
ensureBrowserEnvironment();
|
|
69
89
|
super(baseConfig);
|
|
@@ -79,41 +99,68 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
79
99
|
? Math.floor(config.inboxCapacity)
|
|
80
100
|
: DEFAULT_INBOX_CAPACITY;
|
|
81
101
|
this.inbox = new bounded_async_queue_js_1.BoundedAsyncQueue(preferredCapacity);
|
|
102
|
+
this.inboxCapacity = preferredCapacity;
|
|
82
103
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
104
|
+
const normalizedLocalNodeId = InPageConnector.normalizeNodeId(config.localNodeId);
|
|
105
|
+
if (!normalizedLocalNodeId) {
|
|
106
|
+
throw new Error('InPageConnector requires a non-empty localNodeId');
|
|
107
|
+
}
|
|
108
|
+
this.localNodeId = normalizedLocalNodeId;
|
|
109
|
+
this.targetNodeId = InPageConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
83
110
|
logger.debug('inpage_connector_initialized', {
|
|
84
111
|
channel: this.channelName,
|
|
85
112
|
connector_id: this.connectorId,
|
|
113
|
+
local_node_id: this.localNodeId,
|
|
114
|
+
target_node_id: this.targetNodeId ?? null,
|
|
115
|
+
inbox_capacity: preferredCapacity,
|
|
86
116
|
});
|
|
87
117
|
this.onMsg = (event) => {
|
|
118
|
+
if (!this.listenerRegistered) {
|
|
119
|
+
logger.warning('inpage_message_after_unregister', {
|
|
120
|
+
channel: this.channelName,
|
|
121
|
+
connector_id: this.connectorId,
|
|
122
|
+
timestamp: new Date().toISOString(),
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
88
126
|
const messageEvent = event;
|
|
89
127
|
const message = messageEvent.data;
|
|
90
128
|
logger.debug('inpage_raw_event', {
|
|
91
129
|
channel: this.channelName,
|
|
92
130
|
connector_id: this.connectorId,
|
|
93
|
-
message_type: message && typeof message === 'object'
|
|
94
|
-
|
|
95
|
-
payload_type: message && typeof message === 'object'
|
|
96
|
-
? message?.payload instanceof Uint8Array
|
|
97
|
-
? 'Uint8Array'
|
|
98
|
-
: message?.payload instanceof ArrayBuffer
|
|
99
|
-
? 'ArrayBuffer'
|
|
100
|
-
: typeof message?.payload
|
|
131
|
+
message_type: message && typeof message === 'object'
|
|
132
|
+
? message.constructor?.name ?? typeof message
|
|
101
133
|
: typeof message,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
: undefined,
|
|
105
|
-
payload_keys: message && typeof message === 'object' && message?.payload && typeof message?.payload === 'object'
|
|
106
|
-
? Object.keys(message.payload).slice(0, 5)
|
|
107
|
-
: undefined,
|
|
134
|
+
has_sender_id: Boolean(message?.senderId),
|
|
135
|
+
has_sender_node_id: Boolean(message?.senderNodeId),
|
|
108
136
|
});
|
|
109
137
|
if (!message || typeof message !== 'object') {
|
|
110
138
|
return;
|
|
111
139
|
}
|
|
112
140
|
const busMessage = message;
|
|
113
|
-
|
|
141
|
+
const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
|
|
142
|
+
? busMessage.senderId
|
|
143
|
+
: null;
|
|
144
|
+
const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
145
|
+
if (!senderId || !senderNodeId) {
|
|
146
|
+
logger.debug('inpage_message_rejected', {
|
|
147
|
+
channel: this.channelName,
|
|
148
|
+
connector_id: this.connectorId,
|
|
149
|
+
reason: 'missing_sender_metadata',
|
|
150
|
+
});
|
|
114
151
|
return;
|
|
115
152
|
}
|
|
116
|
-
if (
|
|
153
|
+
if (senderId === this.connectorId || senderNodeId === this.localNodeId) {
|
|
154
|
+
logger.debug('inpage_message_rejected', {
|
|
155
|
+
channel: this.channelName,
|
|
156
|
+
connector_id: this.connectorId,
|
|
157
|
+
reason: 'self_echo',
|
|
158
|
+
sender_node_id: senderNodeId,
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const incomingTargetNodeId = InPageConnector.normalizeTargetNodeId(busMessage.targetNodeId);
|
|
163
|
+
if (!this._shouldAcceptMessageFromBus(senderNodeId, incomingTargetNodeId)) {
|
|
117
164
|
return;
|
|
118
165
|
}
|
|
119
166
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -127,7 +174,9 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
127
174
|
}
|
|
128
175
|
logger.debug('inpage_message_received', {
|
|
129
176
|
channel: this.channelName,
|
|
130
|
-
sender_id:
|
|
177
|
+
sender_id: senderId,
|
|
178
|
+
sender_node_id: senderNodeId,
|
|
179
|
+
target_node_id: incomingTargetNodeId ?? null,
|
|
131
180
|
connector_id: this.connectorId,
|
|
132
181
|
payload_length: payload.byteLength,
|
|
133
182
|
});
|
|
@@ -135,15 +184,27 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
135
184
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
136
185
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
137
186
|
if (accepted) {
|
|
187
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
188
|
+
source: 'listener',
|
|
189
|
+
enqueue_strategy: 'try',
|
|
190
|
+
payload_length: payload.byteLength,
|
|
191
|
+
});
|
|
138
192
|
return;
|
|
139
193
|
}
|
|
140
194
|
}
|
|
141
195
|
this.inbox.enqueue(payload);
|
|
196
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
197
|
+
source: 'listener',
|
|
198
|
+
enqueue_strategy: 'enqueue',
|
|
199
|
+
payload_length: payload.byteLength,
|
|
200
|
+
});
|
|
142
201
|
}
|
|
143
202
|
catch (error) {
|
|
144
203
|
if (error instanceof bounded_async_queue_js_1.QueueFullError) {
|
|
145
204
|
logger.warning('inpage_receive_queue_full', {
|
|
146
205
|
channel: this.channelName,
|
|
206
|
+
inbox_capacity: this.inboxCapacity,
|
|
207
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
147
208
|
});
|
|
148
209
|
}
|
|
149
210
|
else {
|
|
@@ -250,15 +311,25 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
250
311
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
251
312
|
const accepted = this.inbox.tryEnqueue(item);
|
|
252
313
|
if (accepted) {
|
|
314
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
315
|
+
enqueue_strategy: 'try',
|
|
316
|
+
item_type: this._describeInboxItem(item),
|
|
317
|
+
});
|
|
253
318
|
return;
|
|
254
319
|
}
|
|
255
320
|
}
|
|
256
321
|
this.inbox.enqueue(item);
|
|
322
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
323
|
+
enqueue_strategy: 'enqueue',
|
|
324
|
+
item_type: this._describeInboxItem(item),
|
|
325
|
+
});
|
|
257
326
|
}
|
|
258
327
|
catch (error) {
|
|
259
328
|
if (error instanceof bounded_async_queue_js_1.QueueFullError) {
|
|
260
329
|
logger.warning('inpage_push_queue_full', {
|
|
261
330
|
channel: this.channelName,
|
|
331
|
+
inbox_capacity: this.inboxCapacity,
|
|
332
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
262
333
|
});
|
|
263
334
|
throw error;
|
|
264
335
|
}
|
|
@@ -271,25 +342,52 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
271
342
|
}
|
|
272
343
|
async _transportSendBytes(data) {
|
|
273
344
|
ensureBrowserEnvironment();
|
|
345
|
+
const targetNodeId = this.targetNodeId ?? '*';
|
|
274
346
|
logger.debug('inpage_message_sending', {
|
|
275
347
|
channel: this.channelName,
|
|
276
348
|
sender_id: this.connectorId,
|
|
349
|
+
sender_node_id: this.localNodeId,
|
|
350
|
+
target_node_id: targetNodeId,
|
|
277
351
|
});
|
|
278
352
|
const event = new MessageEvent(this.channelName, {
|
|
279
353
|
data: {
|
|
280
354
|
senderId: this.connectorId,
|
|
355
|
+
senderNodeId: this.localNodeId,
|
|
356
|
+
targetNodeId,
|
|
281
357
|
payload: data,
|
|
282
358
|
},
|
|
283
359
|
});
|
|
284
360
|
getSharedBus().dispatchEvent(event);
|
|
285
361
|
}
|
|
286
362
|
async _transportReceive() {
|
|
287
|
-
|
|
363
|
+
const item = await this.inbox.dequeue();
|
|
364
|
+
this.logInboxSnapshot('inpage_inbox_dequeued', {
|
|
365
|
+
item_type: this._describeInboxItem(item),
|
|
366
|
+
});
|
|
367
|
+
return item;
|
|
288
368
|
}
|
|
289
369
|
async _transportClose(code, reason) {
|
|
370
|
+
logger.debug('inpage_transport_closing', {
|
|
371
|
+
channel: this.channelName,
|
|
372
|
+
connector_id: this.connectorId,
|
|
373
|
+
code,
|
|
374
|
+
reason,
|
|
375
|
+
listener_registered: this.listenerRegistered,
|
|
376
|
+
timestamp: new Date().toISOString(),
|
|
377
|
+
});
|
|
290
378
|
if (this.listenerRegistered) {
|
|
379
|
+
logger.debug('inpage_removing_listener', {
|
|
380
|
+
channel: this.channelName,
|
|
381
|
+
connector_id: this.connectorId,
|
|
382
|
+
timestamp: new Date().toISOString(),
|
|
383
|
+
});
|
|
291
384
|
getSharedBus().removeEventListener(this.channelName, this.onMsg);
|
|
292
385
|
this.listenerRegistered = false;
|
|
386
|
+
logger.debug('inpage_listener_removed', {
|
|
387
|
+
channel: this.channelName,
|
|
388
|
+
connector_id: this.connectorId,
|
|
389
|
+
timestamp: new Date().toISOString(),
|
|
390
|
+
});
|
|
293
391
|
}
|
|
294
392
|
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
295
393
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
@@ -307,5 +405,102 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
307
405
|
}
|
|
308
406
|
return rawOrEnvelope;
|
|
309
407
|
}
|
|
408
|
+
_isWildcardTarget() {
|
|
409
|
+
return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
|
|
410
|
+
}
|
|
411
|
+
_shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
|
|
412
|
+
if (this._isWildcardTarget()) {
|
|
413
|
+
if (targetNodeId &&
|
|
414
|
+
targetNodeId !== '*' &&
|
|
415
|
+
targetNodeId !== this.localNodeId) {
|
|
416
|
+
logger.debug('inpage_message_rejected', {
|
|
417
|
+
channel: this.channelName,
|
|
418
|
+
connector_id: this.connectorId,
|
|
419
|
+
reason: 'wildcard_target_mismatch',
|
|
420
|
+
sender_node_id: senderNodeId,
|
|
421
|
+
target_node_id: targetNodeId,
|
|
422
|
+
local_node_id: this.localNodeId,
|
|
423
|
+
});
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
const expectedSender = this.targetNodeId;
|
|
429
|
+
if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
|
|
430
|
+
logger.debug('inpage_message_rejected', {
|
|
431
|
+
channel: this.channelName,
|
|
432
|
+
connector_id: this.connectorId,
|
|
433
|
+
reason: 'unexpected_sender',
|
|
434
|
+
expected_sender_node_id: expectedSender,
|
|
435
|
+
sender_node_id: senderNodeId,
|
|
436
|
+
local_node_id: this.localNodeId,
|
|
437
|
+
});
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
if (targetNodeId &&
|
|
441
|
+
targetNodeId !== '*' &&
|
|
442
|
+
targetNodeId !== this.localNodeId) {
|
|
443
|
+
logger.debug('inpage_message_rejected', {
|
|
444
|
+
channel: this.channelName,
|
|
445
|
+
connector_id: this.connectorId,
|
|
446
|
+
reason: 'unexpected_target',
|
|
447
|
+
sender_node_id: senderNodeId,
|
|
448
|
+
target_node_id: targetNodeId,
|
|
449
|
+
local_node_id: this.localNodeId,
|
|
450
|
+
});
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
_describeInboxItem(item) {
|
|
456
|
+
if (item instanceof Uint8Array) {
|
|
457
|
+
return 'bytes';
|
|
458
|
+
}
|
|
459
|
+
if (item.envelope) {
|
|
460
|
+
return 'channel_message';
|
|
461
|
+
}
|
|
462
|
+
if (item.frame) {
|
|
463
|
+
return 'envelope';
|
|
464
|
+
}
|
|
465
|
+
return 'unknown';
|
|
466
|
+
}
|
|
467
|
+
logInboxSnapshot(event, extra = {}) {
|
|
468
|
+
logger.debug(event, {
|
|
469
|
+
channel: this.channelName,
|
|
470
|
+
connector_id: this.connectorId,
|
|
471
|
+
connector_state: this.state,
|
|
472
|
+
inbox_capacity: this.inboxCapacity,
|
|
473
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
474
|
+
...extra,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
setTargetNodeId(nodeId) {
|
|
478
|
+
const normalized = InPageConnector.normalizeNodeId(nodeId);
|
|
479
|
+
if (!normalized) {
|
|
480
|
+
throw new Error('InPageConnector target node id must be a non-empty string');
|
|
481
|
+
}
|
|
482
|
+
if (normalized === '*') {
|
|
483
|
+
this.setWildcardTarget();
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
this.targetNodeId = normalized;
|
|
487
|
+
logger.debug('inpage_target_updated', {
|
|
488
|
+
channel: this.channelName,
|
|
489
|
+
connector_id: this.connectorId,
|
|
490
|
+
local_node_id: this.localNodeId,
|
|
491
|
+
target_node_id: this.targetNodeId,
|
|
492
|
+
target_mode: 'direct',
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
setWildcardTarget() {
|
|
496
|
+
this.targetNodeId = '*';
|
|
497
|
+
logger.debug('inpage_target_updated', {
|
|
498
|
+
channel: this.channelName,
|
|
499
|
+
connector_id: this.connectorId,
|
|
500
|
+
local_node_id: this.localNodeId,
|
|
501
|
+
target_node_id: this.targetNodeId,
|
|
502
|
+
target_mode: 'wildcard',
|
|
503
|
+
});
|
|
504
|
+
}
|
|
310
505
|
}
|
|
311
506
|
exports.InPageConnector = InPageConnector;
|
|
@@ -282,7 +282,7 @@ class InPageListener extends transport_listener_js_1.TransportListener {
|
|
|
282
282
|
node: routingNode,
|
|
283
283
|
});
|
|
284
284
|
const selection = grant_selection_policy_js_1.defaultGrantSelectionPolicy.selectCallbackGrant(selectionContext);
|
|
285
|
-
connectorConfig = this._grantToConnectorConfig(selection.grant);
|
|
285
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, this._grantToConnectorConfig(selection.grant));
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|
|
288
288
|
logger.debug('inpage_listener_grant_selection_failed', {
|
|
@@ -290,13 +290,13 @@ class InPageListener extends transport_listener_js_1.TransportListener {
|
|
|
290
290
|
system_id: systemId,
|
|
291
291
|
error: error instanceof Error ? error.message : String(error),
|
|
292
292
|
});
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
293
|
+
const fallbackConfig = this._extractInPageConnectorConfig(frame) ??
|
|
294
|
+
{
|
|
295
|
+
type: inpage_connector_js_1.INPAGE_CONNECTOR_TYPE,
|
|
296
|
+
channelName: this._channelName,
|
|
297
|
+
inboxCapacity: this._inboxCapacity,
|
|
298
|
+
};
|
|
299
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, fallbackConfig);
|
|
300
300
|
}
|
|
301
301
|
try {
|
|
302
302
|
const connector = await routingNode.createOriginConnector({
|
|
@@ -415,6 +415,65 @@ class InPageListener extends transport_listener_js_1.TransportListener {
|
|
|
415
415
|
typeof frame === 'object' &&
|
|
416
416
|
frame.type === 'NodeAttach');
|
|
417
417
|
}
|
|
418
|
+
_buildConnectorConfigForSystem(systemId, baseConfig) {
|
|
419
|
+
const localNodeId = this._requireLocalNodeId();
|
|
420
|
+
const targetSystemId = this._normalizeNodeId(systemId);
|
|
421
|
+
if (!targetSystemId) {
|
|
422
|
+
throw new Error('InPageListener requires a valid system id for connector creation');
|
|
423
|
+
}
|
|
424
|
+
const candidate = baseConfig ?? null;
|
|
425
|
+
const channelCandidate = candidate && 'channelName' in candidate
|
|
426
|
+
? candidate.channelName
|
|
427
|
+
: undefined;
|
|
428
|
+
const inboxCandidate = candidate && 'inboxCapacity' in candidate
|
|
429
|
+
? candidate.inboxCapacity
|
|
430
|
+
: undefined;
|
|
431
|
+
const targetCandidate = candidate && 'initialTargetNodeId' in candidate
|
|
432
|
+
? candidate.initialTargetNodeId
|
|
433
|
+
: undefined;
|
|
434
|
+
const channelName = typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
|
|
435
|
+
? channelCandidate.trim()
|
|
436
|
+
: this._channelName;
|
|
437
|
+
const inboxCapacity = typeof inboxCandidate === 'number' &&
|
|
438
|
+
Number.isFinite(inboxCandidate) &&
|
|
439
|
+
inboxCandidate > 0
|
|
440
|
+
? Math.floor(inboxCandidate)
|
|
441
|
+
: this._inboxCapacity;
|
|
442
|
+
const normalizedTarget = this._normalizeTargetNodeId(targetCandidate);
|
|
443
|
+
return {
|
|
444
|
+
type: inpage_connector_js_1.INPAGE_CONNECTOR_TYPE,
|
|
445
|
+
channelName,
|
|
446
|
+
inboxCapacity,
|
|
447
|
+
localNodeId,
|
|
448
|
+
initialTargetNodeId: normalizedTarget ?? targetSystemId,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
_requireLocalNodeId() {
|
|
452
|
+
if (!this._routingNode) {
|
|
453
|
+
throw new Error('InPageListener requires routing node context');
|
|
454
|
+
}
|
|
455
|
+
const normalized = this._normalizeNodeId(this._routingNode.id);
|
|
456
|
+
if (!normalized) {
|
|
457
|
+
throw new Error('InPageListener requires routing node with a stable identifier');
|
|
458
|
+
}
|
|
459
|
+
return normalized;
|
|
460
|
+
}
|
|
461
|
+
_normalizeNodeId(value) {
|
|
462
|
+
if (typeof value !== 'string') {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
const trimmed = value.trim();
|
|
466
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
467
|
+
}
|
|
468
|
+
_normalizeTargetNodeId(value) {
|
|
469
|
+
if (value === undefined || value === null) {
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
if (value === '*') {
|
|
473
|
+
return '*';
|
|
474
|
+
}
|
|
475
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
476
|
+
}
|
|
418
477
|
}
|
|
419
478
|
exports.InPageListener = InPageListener;
|
|
420
479
|
function getInPageListenerInstance() {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Cross-platform structured logging, async task management, and general utilities for Naylence Fame runtime
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.normalizeEnvelopeSnapshot = exports.throttle = exports.debounce = exports.retryWithBackoff = exports.withTimeout = exports.delay = exports.waitForAllSettled = exports.waitForAll = exports.waitForAny = exports.withLock = exports.AsyncLock = exports.TaskSpawner = exports.EnvelopeContext = exports.withEnvelopeContextAsync = exports.withEnvelopeContext = exports.currentTraceId = exports.getCurrentEnvelope = exports.pinoTransport = exports.consoleTransport = exports.stringifyNonPrimitives = exports.dropEmpty = exports.addEnvelopeFields = exports.addLogLevel = exports.addTimestamp = exports.LogLevelNames = exports.LogLevel = exports.enableLogging = exports.basicConfig = exports.getLogger = void 0;
|
|
8
|
+
exports.normalizeEnvelopeSnapshot = exports.safeImport = exports.throttle = exports.debounce = exports.retryWithBackoff = exports.withTimeout = exports.delay = exports.waitForAllSettled = exports.waitForAll = exports.waitForAny = exports.withLock = exports.AsyncLock = exports.TaskSpawner = exports.EnvelopeContext = exports.withEnvelopeContextAsync = exports.withEnvelopeContext = exports.currentTraceId = exports.getCurrentEnvelope = exports.pinoTransport = exports.consoleTransport = exports.stringifyNonPrimitives = exports.dropEmpty = exports.addEnvelopeFields = exports.addLogLevel = exports.addTimestamp = exports.LogLevelNames = exports.LogLevel = exports.enableLogging = exports.basicConfig = exports.getLogger = void 0;
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
// Export the main logging API
|
|
11
11
|
var logging_js_1 = require("./logging.js");
|
|
@@ -55,5 +55,7 @@ tslib_1.__exportStar(require("./metrics-emitter.js"), exports);
|
|
|
55
55
|
tslib_1.__exportStar(require("./util.js"), exports);
|
|
56
56
|
tslib_1.__exportStar(require("./logicals.js"), exports);
|
|
57
57
|
tslib_1.__exportStar(require("./ttl-validation.js"), exports);
|
|
58
|
+
var lazy_import_js_1 = require("./lazy-import.js");
|
|
59
|
+
Object.defineProperty(exports, "safeImport", { enumerable: true, get: function () { return lazy_import_js_1.safeImport; } });
|
|
58
60
|
var logging_types_js_1 = require("./logging-types.js");
|
|
59
61
|
Object.defineProperty(exports, "normalizeEnvelopeSnapshot", { enumerable: true, get: function () { return logging_types_js_1.normalizeEnvelopeSnapshot; } });
|
package/dist/cjs/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runOAuth2Server = exports.createOAuth2ServerApp = exports.createOpenIDConfigurationRouter = exports.createOAuth2TokenRouter = exports.createJwksRouter = exports.normalizeExtendedFameConfig = exports.FAME_FABRIC_FACTORY_BASE_TYPE = exports.InProcessFameFabricFactory = exports.InProcessFameFabric = exports.getInPageListenerInstance = exports.InPageListener = exports.getHttpListenerInstance = exports.HttpListener = exports.WebSocketListener = exports.TRANSPORT_LISTENER_FACTORY_BASE_TYPE = exports.TransportListener = exports.getWebsocketListenerInstance = exports.DefaultHttpServer = exports.QueueFullError = exports.HttpStatelessConnector = void 0;
|
|
3
|
+
exports.runOAuth2Server = exports.createOAuth2ServerApp = exports.createOpenIDConfigurationRouter = exports.createOAuth2TokenRouter = exports.createJwksRouter = exports.normalizeExtendedFameConfig = exports.FAME_FABRIC_FACTORY_BASE_TYPE = exports.InProcessFameFabricFactory = exports.InProcessFameFabric = exports.safeImport = exports.getInPageListenerInstance = exports.InPageListener = exports.getHttpListenerInstance = exports.HttpListener = exports.WebSocketListener = exports.TRANSPORT_LISTENER_FACTORY_BASE_TYPE = exports.TransportListenerFactory = exports.TransportListener = exports.getWebsocketListenerInstance = exports.DefaultHttpServer = exports.QueueFullError = exports.HttpStatelessConnector = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
require("./naylence/fame/connector/websocket-connector-node-ssl.js");
|
|
6
6
|
// Ensure Node-specific registrations (storage, sqlite, etc.) happen before
|
|
@@ -25,12 +25,15 @@ Object.defineProperty(exports, "QueueFullError", { enumerable: true, get: functi
|
|
|
25
25
|
Object.defineProperty(exports, "DefaultHttpServer", { enumerable: true, get: function () { return index_js_1.DefaultHttpServer; } });
|
|
26
26
|
Object.defineProperty(exports, "getWebsocketListenerInstance", { enumerable: true, get: function () { return index_js_1.getWebsocketListenerInstance; } });
|
|
27
27
|
Object.defineProperty(exports, "TransportListener", { enumerable: true, get: function () { return index_js_1.TransportListener; } });
|
|
28
|
+
Object.defineProperty(exports, "TransportListenerFactory", { enumerable: true, get: function () { return index_js_1.TransportListenerFactory; } });
|
|
28
29
|
Object.defineProperty(exports, "TRANSPORT_LISTENER_FACTORY_BASE_TYPE", { enumerable: true, get: function () { return index_js_1.TRANSPORT_LISTENER_FACTORY_BASE_TYPE; } });
|
|
29
30
|
Object.defineProperty(exports, "WebSocketListener", { enumerable: true, get: function () { return index_js_1.WebSocketListener; } });
|
|
30
31
|
Object.defineProperty(exports, "HttpListener", { enumerable: true, get: function () { return index_js_1.HttpListener; } });
|
|
31
32
|
Object.defineProperty(exports, "getHttpListenerInstance", { enumerable: true, get: function () { return index_js_1.getHttpListenerInstance; } });
|
|
32
33
|
Object.defineProperty(exports, "InPageListener", { enumerable: true, get: function () { return index_js_1.InPageListener; } });
|
|
33
34
|
Object.defineProperty(exports, "getInPageListenerInstance", { enumerable: true, get: function () { return index_js_1.getInPageListenerInstance; } });
|
|
35
|
+
var lazy_import_js_1 = require("./naylence/fame/util/lazy-import.js");
|
|
36
|
+
Object.defineProperty(exports, "safeImport", { enumerable: true, get: function () { return lazy_import_js_1.safeImport; } });
|
|
34
37
|
var index_js_2 = require("./naylence/fame/fabric/index.js");
|
|
35
38
|
Object.defineProperty(exports, "InProcessFameFabric", { enumerable: true, get: function () { return index_js_2.InProcessFameFabric; } });
|
|
36
39
|
Object.defineProperty(exports, "InProcessFameFabricFactory", { enumerable: true, get: function () { return index_js_2.InProcessFameFabricFactory; } });
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated during build - do not edit manually
|
|
3
|
-
// Generated from package.json version: 0.3.
|
|
3
|
+
// Generated from package.json version: 0.3.6-test.001
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VERSION = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* The package version, injected at build time.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.VERSION = '0.3.
|
|
10
|
+
exports.VERSION = '0.3.6-test.001';
|
|
@@ -24,7 +24,7 @@ export { BroadcastChannelConnector, BROADCAST_CHANNEL_CONNECTOR_TYPE, } from './
|
|
|
24
24
|
export { _NoopFlowController } from './noop-flow-controller.js';
|
|
25
25
|
// Transport listener
|
|
26
26
|
export { TransportListener } from './transport-listener.js';
|
|
27
|
-
export { TRANSPORT_LISTENER_FACTORY_BASE_TYPE } from './transport-listener-factory.js';
|
|
27
|
+
export { TransportListenerFactory, TRANSPORT_LISTENER_FACTORY_BASE_TYPE } from './transport-listener-factory.js';
|
|
28
28
|
export { DefaultHttpServer } from './default-http-server.js';
|
|
29
29
|
export { WebSocketListener, getWebsocketListenerInstance, } from './websocket-listener.js';
|
|
30
30
|
export { HttpListener, getHttpListenerInstance } from './http-listener.js';
|
|
@@ -65,8 +65,16 @@ export class InPageConnectorFactory extends ConnectorFactory {
|
|
|
65
65
|
}
|
|
66
66
|
const normalized = this._normalizeConfig(config);
|
|
67
67
|
const options = (factoryArgs[0] ?? {});
|
|
68
|
+
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
69
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
|
|
70
|
+
if (!localNodeId) {
|
|
71
|
+
throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
|
|
72
|
+
}
|
|
68
73
|
const channelName = normalized.channelName ?? DEFAULT_CHANNEL;
|
|
69
74
|
const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
|
|
75
|
+
const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
|
|
76
|
+
const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
|
|
77
|
+
const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
|
|
70
78
|
const baseConfig = {
|
|
71
79
|
drainTimeout: normalized.drainTimeout,
|
|
72
80
|
flowControl: normalized.flowControl,
|
|
@@ -81,6 +89,8 @@ export class InPageConnectorFactory extends ConnectorFactory {
|
|
|
81
89
|
type: INPAGE_CONNECTOR_TYPE,
|
|
82
90
|
channelName,
|
|
83
91
|
inboxCapacity,
|
|
92
|
+
localNodeId,
|
|
93
|
+
initialTargetNodeId: resolvedTarget,
|
|
84
94
|
};
|
|
85
95
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
86
96
|
if (options.authorization) {
|
|
@@ -116,6 +126,16 @@ export class InPageConnectorFactory extends ConnectorFactory {
|
|
|
116
126
|
capacity > 0) {
|
|
117
127
|
normalized.inboxCapacity = Math.floor(capacity);
|
|
118
128
|
}
|
|
129
|
+
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
130
|
+
const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
|
|
131
|
+
if (normalizedLocalNodeId) {
|
|
132
|
+
normalized.localNodeId = normalizedLocalNodeId;
|
|
133
|
+
}
|
|
134
|
+
const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
|
|
135
|
+
const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
|
|
136
|
+
if (normalizedTarget) {
|
|
137
|
+
normalized.initialTargetNodeId = normalizedTarget;
|
|
138
|
+
}
|
|
119
139
|
if (typeof candidate.flowControl === 'boolean') {
|
|
120
140
|
normalized.flowControl = candidate.flowControl;
|
|
121
141
|
}
|
|
@@ -154,5 +174,21 @@ export class InPageConnectorFactory extends ConnectorFactory {
|
|
|
154
174
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
|
|
155
175
|
return normalized;
|
|
156
176
|
}
|
|
177
|
+
_normalizeNodeId(value) {
|
|
178
|
+
if (typeof value !== 'string') {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const trimmed = value.trim();
|
|
182
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
183
|
+
}
|
|
184
|
+
_normalizeTargetNodeId(value) {
|
|
185
|
+
if (value === undefined || value === null) {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
if (value === '*') {
|
|
189
|
+
return '*';
|
|
190
|
+
}
|
|
191
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
192
|
+
}
|
|
157
193
|
}
|
|
158
194
|
export default InPageConnectorFactory;
|