@naylence/runtime 0.3.6 → 0.3.9
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 +262 -172
- package/dist/browser/index.mjs +261 -173
- package/dist/cjs/_env-shim.js +3 -1
- package/dist/cjs/naylence/fame/config/extended-fame-config.js +2 -1
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector-factory.js +12 -4
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +14 -6
- package/dist/cjs/naylence/fame/connector/broadcast-channel-listener-factory.js +3 -1
- package/dist/cjs/naylence/fame/connector/broadcast-channel-listener.js +11 -7
- package/dist/cjs/naylence/fame/connector/index.js +2 -1
- package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +2 -1
- package/dist/cjs/naylence/fame/connector/inpage-connector.js +13 -6
- package/dist/cjs/naylence/fame/connector/inpage-listener-factory.js +4 -4
- package/dist/cjs/naylence/fame/connector/inpage-listener.js +5 -2
- package/dist/cjs/naylence/fame/delivery/default-delivery-tracker.js +4 -62
- package/dist/cjs/naylence/fame/fabric/fabric-registry.js +41 -0
- package/dist/cjs/naylence/fame/fabric/in-process-fame-fabric.js +3 -0
- package/dist/cjs/naylence/fame/fabric/index.js +3 -1
- package/dist/cjs/naylence/fame/grants/broadcast-channel-connection-grant.js +6 -3
- package/dist/cjs/naylence/fame/grants/inpage-connection-grant.js +4 -2
- package/dist/cjs/naylence/fame/http/oauth2-token-router.js +9 -9
- package/dist/cjs/naylence/fame/node/admission/default-node-attach-client.js +34 -5
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +40 -8
- package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.js +10 -6
- package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider.js +1 -2
- package/dist/cjs/naylence/fame/security/default-security-manager.js +2 -1
- package/dist/cjs/naylence/fame/security/trust-store/noop-trust-store-provider-factory.js +2 -2
- package/dist/cjs/naylence/fame/security/trust-store/trust-store-provider-factory.js +2 -2
- package/dist/cjs/naylence/fame/util/index.js +3 -1
- package/dist/cjs/node.js +4 -1
- package/dist/cjs/runtime-isomorphic.js +4 -1
- package/dist/cjs/version.js +2 -2
- package/dist/esm/_env-shim.js +3 -1
- package/dist/esm/browser.js +2 -2
- package/dist/esm/naylence/fame/config/extended-fame-config.js +2 -1
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +12 -4
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +14 -6
- package/dist/esm/naylence/fame/connector/broadcast-channel-listener-factory.js +3 -1
- package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +11 -7
- package/dist/esm/naylence/fame/connector/index.js +2 -2
- package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +2 -1
- package/dist/esm/naylence/fame/connector/inpage-connector.js +13 -6
- package/dist/esm/naylence/fame/connector/inpage-listener-factory.js +4 -4
- package/dist/esm/naylence/fame/connector/inpage-listener.js +5 -2
- package/dist/esm/naylence/fame/delivery/default-delivery-tracker.js +4 -62
- package/dist/esm/naylence/fame/fabric/fabric-registry.js +37 -0
- package/dist/esm/naylence/fame/fabric/in-process-fame-fabric.js +3 -0
- package/dist/esm/naylence/fame/fabric/index.js +1 -0
- package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +6 -3
- package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +4 -2
- package/dist/esm/naylence/fame/http/oauth2-token-router.js +9 -9
- package/dist/esm/naylence/fame/node/admission/default-node-attach-client.js +34 -5
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +40 -8
- package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.js +10 -6
- package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider.js +1 -2
- package/dist/esm/naylence/fame/security/default-security-manager.js +2 -1
- package/dist/esm/naylence/fame/security/index.js +1 -1
- package/dist/esm/naylence/fame/security/trust-store/noop-trust-store-provider-factory.js +3 -3
- package/dist/esm/naylence/fame/security/trust-store/trust-store-provider-factory.js +3 -3
- package/dist/esm/naylence/fame/util/index.js +1 -0
- package/dist/esm/node.js +2 -1
- package/dist/esm/runtime-isomorphic.js +2 -0
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +259 -171
- package/dist/node/index.mjs +258 -172
- package/dist/node/node.cjs +225 -136
- package/dist/node/node.mjs +223 -137
- package/dist/types/browser.d.ts +2 -2
- package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +1 -0
- package/dist/types/naylence/fame/connector/index.d.ts +3 -3
- package/dist/types/naylence/fame/delivery/default-delivery-tracker.d.ts +0 -6
- package/dist/types/naylence/fame/fabric/fabric-registry.d.ts +29 -0
- package/dist/types/naylence/fame/fabric/index.d.ts +1 -0
- package/dist/types/naylence/fame/node/admission/default-node-attach-client.d.ts +1 -0
- package/dist/types/naylence/fame/security/index.d.ts +1 -1
- package/dist/types/naylence/fame/security/trust-store/noop-trust-store-provider-factory.d.ts +3 -3
- package/dist/types/naylence/fame/security/trust-store/trust-store-provider-factory.d.ts +4 -4
- package/dist/types/naylence/fame/security/trust-store/trust-store-provider.d.ts +5 -5
- package/dist/types/naylence/fame/util/index.d.ts +1 -0
- package/dist/types/node.d.ts +2 -1
- package/dist/types/runtime-isomorphic.d.ts +1 -0
- 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.
|
|
17
|
+
// Generated from package.json version: 0.3.9
|
|
18
18
|
/**
|
|
19
19
|
* The package version, injected at build time.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
const VERSION = '0.3.
|
|
22
|
+
const VERSION = '0.3.9';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -2248,6 +2248,50 @@ function validateKeyCorrelationTtlSec(ttlSec) {
|
|
|
2248
2248
|
});
|
|
2249
2249
|
}
|
|
2250
2250
|
|
|
2251
|
+
function isModuleNotFoundError(error) {
|
|
2252
|
+
if (!(error instanceof Error)) {
|
|
2253
|
+
return false;
|
|
2254
|
+
}
|
|
2255
|
+
const message = error.message || '';
|
|
2256
|
+
if (message.includes('Cannot find module') ||
|
|
2257
|
+
message.includes('ERR_MODULE_NOT_FOUND') ||
|
|
2258
|
+
message.includes('MODULE_NOT_FOUND')) {
|
|
2259
|
+
return true;
|
|
2260
|
+
}
|
|
2261
|
+
const code = error.code;
|
|
2262
|
+
if (typeof code === 'string') {
|
|
2263
|
+
return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
|
|
2264
|
+
}
|
|
2265
|
+
return false;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
|
|
2269
|
+
*/
|
|
2270
|
+
async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
2271
|
+
const options = typeof dependencyNameOrOptions === 'string'
|
|
2272
|
+
? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
|
|
2273
|
+
: dependencyNameOrOptions;
|
|
2274
|
+
const dependencyName = options.dependencyName;
|
|
2275
|
+
try {
|
|
2276
|
+
return await loader();
|
|
2277
|
+
}
|
|
2278
|
+
catch (error) {
|
|
2279
|
+
if (isModuleNotFoundError(error)) {
|
|
2280
|
+
const message = options.helpMessage ??
|
|
2281
|
+
`Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
|
|
2282
|
+
const enrichedError = new Error(message);
|
|
2283
|
+
try {
|
|
2284
|
+
enrichedError.cause = error;
|
|
2285
|
+
}
|
|
2286
|
+
catch {
|
|
2287
|
+
// Ignore environments that do not support attaching a cause.
|
|
2288
|
+
}
|
|
2289
|
+
throw enrichedError;
|
|
2290
|
+
}
|
|
2291
|
+
throw error;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2251
2295
|
/**
|
|
2252
2296
|
* flow_controller.ts - credit window management with cooperative back-pressure.
|
|
2253
2297
|
*
|
|
@@ -3452,50 +3496,6 @@ function normalizeSecretSource(value) {
|
|
|
3452
3496
|
return SecretSource.normalize(value);
|
|
3453
3497
|
}
|
|
3454
3498
|
|
|
3455
|
-
function isModuleNotFoundError(error) {
|
|
3456
|
-
if (!(error instanceof Error)) {
|
|
3457
|
-
return false;
|
|
3458
|
-
}
|
|
3459
|
-
const message = error.message || '';
|
|
3460
|
-
if (message.includes('Cannot find module') ||
|
|
3461
|
-
message.includes('ERR_MODULE_NOT_FOUND') ||
|
|
3462
|
-
message.includes('MODULE_NOT_FOUND')) {
|
|
3463
|
-
return true;
|
|
3464
|
-
}
|
|
3465
|
-
const code = error.code;
|
|
3466
|
-
if (typeof code === 'string') {
|
|
3467
|
-
return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
|
|
3468
|
-
}
|
|
3469
|
-
return false;
|
|
3470
|
-
}
|
|
3471
|
-
/**
|
|
3472
|
-
* Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
|
|
3473
|
-
*/
|
|
3474
|
-
async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
3475
|
-
const options = typeof dependencyNameOrOptions === 'string'
|
|
3476
|
-
? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
|
|
3477
|
-
: dependencyNameOrOptions;
|
|
3478
|
-
const dependencyName = options.dependencyName;
|
|
3479
|
-
try {
|
|
3480
|
-
return await loader();
|
|
3481
|
-
}
|
|
3482
|
-
catch (error) {
|
|
3483
|
-
if (isModuleNotFoundError(error)) {
|
|
3484
|
-
const message = options.helpMessage ??
|
|
3485
|
-
`Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
|
|
3486
|
-
const enrichedError = new Error(message);
|
|
3487
|
-
try {
|
|
3488
|
-
enrichedError.cause = error;
|
|
3489
|
-
}
|
|
3490
|
-
catch {
|
|
3491
|
-
// Ignore environments that do not support attaching a cause.
|
|
3492
|
-
}
|
|
3493
|
-
throw enrichedError;
|
|
3494
|
-
}
|
|
3495
|
-
throw error;
|
|
3496
|
-
}
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
3499
|
const indexedDBConfigSchema = zod.z
|
|
3500
3500
|
.object({
|
|
3501
3501
|
type: zod.z
|
|
@@ -7091,9 +7091,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7091
7091
|
this.ackDoneSince = new Map();
|
|
7092
7092
|
this.replyDoneSince = new Map();
|
|
7093
7093
|
this.pendingAckDispatches = new Set();
|
|
7094
|
-
this.recentlyHandled = new Map();
|
|
7095
|
-
this.recentlyHandledOrder = [];
|
|
7096
|
-
this.recentlyHandledTtlMs = 60000;
|
|
7097
7094
|
this.isPreparingToStop = false;
|
|
7098
7095
|
this.shutdownRequestedAtMs = null;
|
|
7099
7096
|
this.shutdownRetryGraceMs = 1000;
|
|
@@ -7315,22 +7312,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7315
7312
|
}
|
|
7316
7313
|
}
|
|
7317
7314
|
else {
|
|
7318
|
-
const wasRecentlyHandled = await this.lock.runExclusive(async () => this.wasRecentlyHandled(envelope.id));
|
|
7319
|
-
if (wasRecentlyHandled) {
|
|
7320
|
-
logger$12.debug('tracker_duplicate_envelope_recently_handled', {
|
|
7321
|
-
envp_id: envelope.id,
|
|
7322
|
-
});
|
|
7323
|
-
return new TrackedEnvelope({
|
|
7324
|
-
timeoutAtMs: 0,
|
|
7325
|
-
overallTimeoutAtMs: 0,
|
|
7326
|
-
expectedResponseType: envelope.rtype ?? core.FameResponseType.NONE,
|
|
7327
|
-
createdAtMs: Date.now(),
|
|
7328
|
-
status: EnvelopeStatus.HANDLED,
|
|
7329
|
-
mailboxType: MailboxType.INBOX,
|
|
7330
|
-
originalEnvelope: envelope,
|
|
7331
|
-
serviceName: inboxName,
|
|
7332
|
-
});
|
|
7333
|
-
}
|
|
7334
7315
|
tracked = new TrackedEnvelope({
|
|
7335
7316
|
timeoutAtMs: 0,
|
|
7336
7317
|
overallTimeoutAtMs: 0,
|
|
@@ -7352,12 +7333,8 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7352
7333
|
async onEnvelopeHandled(envelope) {
|
|
7353
7334
|
const inbox = this.ensureInbox();
|
|
7354
7335
|
envelope.status = EnvelopeStatus.HANDLED;
|
|
7336
|
+
// Delete the envelope from inbox to prevent growth
|
|
7355
7337
|
await inbox.delete(envelope.originalEnvelope.id);
|
|
7356
|
-
await this.lock.runExclusive(async () => {
|
|
7357
|
-
this.markRecentlyHandled(envelope.originalEnvelope.id);
|
|
7358
|
-
});
|
|
7359
|
-
// Preserve handled envelope to prevent duplicate redelivery during shutdown drains.
|
|
7360
|
-
// await inbox.set(envelope.originalEnvelope.id, envelope);
|
|
7361
7338
|
}
|
|
7362
7339
|
async onEnvelopeHandleFailed(inboxName, envelope, context, error, isFinalFailure = false) {
|
|
7363
7340
|
const inbox = this.ensureInbox();
|
|
@@ -7572,9 +7549,9 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7572
7549
|
});
|
|
7573
7550
|
await this.markDoneSince(this.replyFutures, trackedEnvelope.originalEnvelope.id, this.replyDoneSince);
|
|
7574
7551
|
await this.markDoneSince(this.ackFutures, trackedEnvelope.originalEnvelope.id, this.ackDoneSince);
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7552
|
+
// Note: ACK is already sent in onCorrelatedMessage (lines 655-657)
|
|
7553
|
+
// when the reply envelope is first delivered. No need to send it again here.
|
|
7554
|
+
// Removing this duplicate sendAck call fixes the duplicate DeliveryAck bug.
|
|
7578
7555
|
for (const handler of this.eventHandlers) {
|
|
7579
7556
|
await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
|
|
7580
7557
|
}
|
|
@@ -7724,8 +7701,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
7724
7701
|
}
|
|
7725
7702
|
this.streamDone.clear();
|
|
7726
7703
|
this.correlationToEnvelope.clear();
|
|
7727
|
-
this.recentlyHandled.clear();
|
|
7728
|
-
this.recentlyHandledOrder.length = 0;
|
|
7729
7704
|
return values;
|
|
7730
7705
|
});
|
|
7731
7706
|
for (const timer of timers) {
|
|
@@ -8307,39 +8282,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
|
|
|
8307
8282
|
this.pendingAckDispatches.delete(ackDispatch);
|
|
8308
8283
|
}
|
|
8309
8284
|
}
|
|
8310
|
-
markRecentlyHandled(envelopeId) {
|
|
8311
|
-
const now = Date.now();
|
|
8312
|
-
this.recentlyHandled.set(envelopeId, now);
|
|
8313
|
-
this.recentlyHandledOrder.push(envelopeId);
|
|
8314
|
-
this.trimRecentlyHandled(now);
|
|
8315
|
-
}
|
|
8316
|
-
wasRecentlyHandled(envelopeId) {
|
|
8317
|
-
const now = Date.now();
|
|
8318
|
-
const timestamp = this.recentlyHandled.get(envelopeId);
|
|
8319
|
-
if (timestamp === undefined) {
|
|
8320
|
-
return false;
|
|
8321
|
-
}
|
|
8322
|
-
if (now - timestamp > this.recentlyHandledTtlMs) {
|
|
8323
|
-
this.recentlyHandled.delete(envelopeId);
|
|
8324
|
-
return false;
|
|
8325
|
-
}
|
|
8326
|
-
return true;
|
|
8327
|
-
}
|
|
8328
|
-
trimRecentlyHandled(now) {
|
|
8329
|
-
while (this.recentlyHandledOrder.length > 0) {
|
|
8330
|
-
const candidate = this.recentlyHandledOrder[0];
|
|
8331
|
-
const timestamp = this.recentlyHandled.get(candidate);
|
|
8332
|
-
if (timestamp === undefined) {
|
|
8333
|
-
this.recentlyHandledOrder.shift();
|
|
8334
|
-
continue;
|
|
8335
|
-
}
|
|
8336
|
-
if (now - timestamp <= this.recentlyHandledTtlMs) {
|
|
8337
|
-
break;
|
|
8338
|
-
}
|
|
8339
|
-
this.recentlyHandled.delete(candidate);
|
|
8340
|
-
this.recentlyHandledOrder.shift();
|
|
8341
|
-
}
|
|
8342
|
-
}
|
|
8343
8285
|
getShutdownRetryDeferDelay(nowMs) {
|
|
8344
8286
|
if (!this.isPreparingToStop || this.shutdownRequestedAtMs === null) {
|
|
8345
8287
|
return null;
|
|
@@ -9833,7 +9775,8 @@ const ensureBroadcastEnvironment = () => {
|
|
|
9833
9775
|
};
|
|
9834
9776
|
let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAsyncConnector {
|
|
9835
9777
|
static generateConnectorId() {
|
|
9836
|
-
const globalCrypto = globalThis
|
|
9778
|
+
const globalCrypto = globalThis
|
|
9779
|
+
.crypto;
|
|
9837
9780
|
if (globalCrypto?.randomUUID) {
|
|
9838
9781
|
return globalCrypto.randomUUID();
|
|
9839
9782
|
}
|
|
@@ -9888,7 +9831,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9888
9831
|
this.listenerRegistered = false;
|
|
9889
9832
|
this.visibilityChangeListenerRegistered = false;
|
|
9890
9833
|
this.channelName =
|
|
9891
|
-
typeof config.channelName === 'string' &&
|
|
9834
|
+
typeof config.channelName === 'string' &&
|
|
9835
|
+
config.channelName.trim().length > 0
|
|
9892
9836
|
? config.channelName.trim()
|
|
9893
9837
|
: DEFAULT_CHANNEL$7;
|
|
9894
9838
|
const preferredCapacity = typeof config.inboxCapacity === 'number' &&
|
|
@@ -9912,6 +9856,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9912
9856
|
local_node_id: this.localNodeId,
|
|
9913
9857
|
target_node_id: this.targetNodeId ?? null,
|
|
9914
9858
|
inbox_capacity: preferredCapacity,
|
|
9859
|
+
passive: config.passive ?? false,
|
|
9915
9860
|
timestamp: new Date().toISOString(),
|
|
9916
9861
|
});
|
|
9917
9862
|
this.onMsg = (event) => {
|
|
@@ -9929,7 +9874,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9929
9874
|
channel: this.channelName,
|
|
9930
9875
|
connector_id: this.connectorId,
|
|
9931
9876
|
message_type: message && typeof message === 'object'
|
|
9932
|
-
? message.constructor
|
|
9877
|
+
? (message.constructor
|
|
9878
|
+
?.name ?? typeof message)
|
|
9933
9879
|
: typeof message,
|
|
9934
9880
|
has_sender_id: Boolean(message?.senderId),
|
|
9935
9881
|
has_sender_node_id: Boolean(message?.senderNodeId),
|
|
@@ -10159,7 +10105,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10159
10105
|
timestamp: new Date().toISOString(),
|
|
10160
10106
|
});
|
|
10161
10107
|
}
|
|
10162
|
-
if (this.visibilityChangeListenerRegistered &&
|
|
10108
|
+
if (this.visibilityChangeListenerRegistered &&
|
|
10109
|
+
this.visibilityChangeHandler &&
|
|
10110
|
+
typeof document !== 'undefined') {
|
|
10163
10111
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
10164
10112
|
this.visibilityChangeListenerRegistered = false;
|
|
10165
10113
|
this.visibilityChangeHandler = undefined;
|
|
@@ -10187,7 +10135,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10187
10135
|
return rawOrEnvelope;
|
|
10188
10136
|
}
|
|
10189
10137
|
_isWildcardTarget() {
|
|
10190
|
-
return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
|
|
10138
|
+
return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
|
|
10191
10139
|
}
|
|
10192
10140
|
_shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
|
|
10193
10141
|
if (this._isWildcardTarget()) {
|
|
@@ -10207,7 +10155,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10207
10155
|
return true;
|
|
10208
10156
|
}
|
|
10209
10157
|
const expectedSender = this.targetNodeId;
|
|
10210
|
-
if (expectedSender &&
|
|
10158
|
+
if (expectedSender &&
|
|
10159
|
+
expectedSender !== '*' &&
|
|
10160
|
+
senderNodeId !== expectedSender) {
|
|
10211
10161
|
logger$_.debug('broadcast_channel_message_rejected', {
|
|
10212
10162
|
channel: this.channelName,
|
|
10213
10163
|
connector_id: this.connectorId,
|
|
@@ -10426,14 +10376,16 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
|
|
|
10426
10376
|
type,
|
|
10427
10377
|
purpose,
|
|
10428
10378
|
};
|
|
10429
|
-
const channelValue = candidate.channelName ??
|
|
10379
|
+
const channelValue = candidate.channelName ??
|
|
10380
|
+
candidate['channel_name'];
|
|
10430
10381
|
if (channelValue !== undefined) {
|
|
10431
10382
|
if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
|
|
10432
10383
|
throw new TypeError('BroadcastChannelConnectionGrant "channelName" must be a non-empty string when provided');
|
|
10433
10384
|
}
|
|
10434
10385
|
result.channelName = channelValue.trim();
|
|
10435
10386
|
}
|
|
10436
|
-
const inboxValue = candidate.inboxCapacity ??
|
|
10387
|
+
const inboxValue = candidate.inboxCapacity ??
|
|
10388
|
+
candidate['inbox_capacity'];
|
|
10437
10389
|
if (inboxValue !== undefined) {
|
|
10438
10390
|
if (typeof inboxValue !== 'number' ||
|
|
10439
10391
|
!Number.isFinite(inboxValue) ||
|
|
@@ -10442,7 +10394,8 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
|
|
|
10442
10394
|
}
|
|
10443
10395
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
10444
10396
|
}
|
|
10445
|
-
const windowValue = candidate.initialWindow ??
|
|
10397
|
+
const windowValue = candidate.initialWindow ??
|
|
10398
|
+
candidate['initial_window'];
|
|
10446
10399
|
if (windowValue !== undefined) {
|
|
10447
10400
|
if (typeof windowValue !== 'number' ||
|
|
10448
10401
|
!Number.isFinite(windowValue) ||
|
|
@@ -10779,25 +10732,56 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10779
10732
|
await connector.start(this.wrappedHandler);
|
|
10780
10733
|
this.connector = connector;
|
|
10781
10734
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10735
|
+
logger$Z.debug('callback_grants_before_augmentation', {
|
|
10736
|
+
count: callbackGrants.length,
|
|
10737
|
+
types: callbackGrants.map((g) => g.type),
|
|
10738
|
+
});
|
|
10739
|
+
// Check if we should create a broadcast callback grant before processing connection grants
|
|
10740
|
+
// This prevents adding duplicate broadcast grants
|
|
10741
|
+
const shouldAddBroadcastGrant = this.shouldAdvertiseBroadcastGrant(grant, callbackGrants);
|
|
10742
|
+
const broadcastCallbackGrant = shouldAddBroadcastGrant
|
|
10743
|
+
? this.createBroadcastCallbackGrant(grant)
|
|
10744
|
+
: null;
|
|
10745
|
+
logger$Z.debug('broadcast_callback_grant_check', {
|
|
10746
|
+
should_add: shouldAddBroadcastGrant,
|
|
10747
|
+
grant_created: !!broadcastCallbackGrant,
|
|
10748
|
+
});
|
|
10782
10749
|
// Include admission client's connection grants as callback grants
|
|
10783
10750
|
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
10784
|
-
if (welcome.frame.connectionGrants &&
|
|
10751
|
+
if (welcome.frame.connectionGrants &&
|
|
10752
|
+
Array.isArray(welcome.frame.connectionGrants)) {
|
|
10785
10753
|
for (const grant of welcome.frame.connectionGrants) {
|
|
10786
10754
|
if (grant && typeof grant === 'object') {
|
|
10787
10755
|
// Avoid duplicates by checking if grant already exists
|
|
10788
|
-
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10756
|
+
const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10789
10757
|
if (!isDuplicate) {
|
|
10790
10758
|
callbackGrants.push(grant);
|
|
10759
|
+
logger$Z.debug('added_connection_grant_as_callback', {
|
|
10760
|
+
type: grant.type,
|
|
10761
|
+
});
|
|
10762
|
+
}
|
|
10763
|
+
else {
|
|
10764
|
+
logger$Z.debug('skipped_duplicate_connection_grant', {
|
|
10765
|
+
type: grant.type,
|
|
10766
|
+
});
|
|
10791
10767
|
}
|
|
10792
10768
|
}
|
|
10793
10769
|
}
|
|
10794
10770
|
}
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10771
|
+
// Add broadcast grant after connection grants to ensure we don't duplicate
|
|
10772
|
+
// any broadcast grants that may have been in connectionGrants
|
|
10773
|
+
if (broadcastCallbackGrant &&
|
|
10774
|
+
this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10775
|
+
callbackGrants.push(broadcastCallbackGrant);
|
|
10776
|
+
logger$Z.debug('added_broadcast_callback_grant');
|
|
10777
|
+
}
|
|
10778
|
+
else if (broadcastCallbackGrant) {
|
|
10779
|
+
logger$Z.debug('skipped_duplicate_broadcast_callback_grant');
|
|
10800
10780
|
}
|
|
10781
|
+
logger$Z.debug('callback_grants_after_augmentation', {
|
|
10782
|
+
count: callbackGrants.length,
|
|
10783
|
+
types: callbackGrants.map((g) => g.type),
|
|
10784
|
+
});
|
|
10801
10785
|
const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
|
|
10802
10786
|
this.targetSystemId = attachInfo.targetSystemId ?? null;
|
|
10803
10787
|
if (this.targetSystemId) {
|
|
@@ -11038,7 +11022,8 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
11038
11022
|
continue;
|
|
11039
11023
|
}
|
|
11040
11024
|
// Reset ack time if just resumed from pause (prevents immediate timeout)
|
|
11041
|
-
if (previousState === core.ConnectorState.PAUSED &&
|
|
11025
|
+
if (previousState === core.ConnectorState.PAUSED &&
|
|
11026
|
+
currentState === core.ConnectorState.STARTED) {
|
|
11042
11027
|
logger$Z.debug('connector_just_resumed_resetting_ack_time', {
|
|
11043
11028
|
previous_state: previousState,
|
|
11044
11029
|
current_state: currentState,
|
|
@@ -12595,15 +12580,30 @@ class DefaultNodeAttachClient {
|
|
|
12595
12580
|
constructor(options = {}) {
|
|
12596
12581
|
this.buffer = [];
|
|
12597
12582
|
this.inHandshake = false;
|
|
12583
|
+
this.expectedSystemId = null;
|
|
12598
12584
|
this.timeoutMs = options.timeoutMs ?? 10000;
|
|
12599
12585
|
this.attachmentKeyValidator = options.attachmentKeyValidator;
|
|
12600
12586
|
this.replicaStickinessManager = options.replicaStickinessManager ?? null;
|
|
12601
12587
|
}
|
|
12602
12588
|
async attach(node, originType, connector, welcomeFrame, finalHandler, keys, callbackGrants) {
|
|
12603
12589
|
this.inHandshake = true;
|
|
12590
|
+
this.expectedSystemId = welcomeFrame.systemId;
|
|
12604
12591
|
const interimHandler = async (envelope, context) => {
|
|
12605
12592
|
if (this.inHandshake) {
|
|
12606
|
-
|
|
12593
|
+
// Filter: only buffer frames related to our systemId or frames without systemId info
|
|
12594
|
+
const frameSystemId = envelope.frame
|
|
12595
|
+
?.systemId;
|
|
12596
|
+
if (!frameSystemId || frameSystemId === this.expectedSystemId) {
|
|
12597
|
+
this.buffer.push(envelope);
|
|
12598
|
+
}
|
|
12599
|
+
else {
|
|
12600
|
+
// Silently ignore frames from other agents during concurrent handshakes
|
|
12601
|
+
logger$W.debug('handshake_ignoring_frame_from_different_system', {
|
|
12602
|
+
frame_type: envelope.frame.type,
|
|
12603
|
+
frame_system_id: frameSystemId,
|
|
12604
|
+
expected_system_id: this.expectedSystemId,
|
|
12605
|
+
});
|
|
12606
|
+
}
|
|
12607
12607
|
return null;
|
|
12608
12608
|
}
|
|
12609
12609
|
return finalHandler(envelope, context);
|
|
@@ -12730,6 +12730,7 @@ class DefaultNodeAttachClient {
|
|
|
12730
12730
|
parent_id: ackFrame.targetSystemId,
|
|
12731
12731
|
});
|
|
12732
12732
|
this.inHandshake = false;
|
|
12733
|
+
this.expectedSystemId = null;
|
|
12733
12734
|
await connector.replaceHandler(finalHandler);
|
|
12734
12735
|
while (this.buffer.length > 0) {
|
|
12735
12736
|
const bufferedEnvelope = this.buffer.shift();
|
|
@@ -12787,7 +12788,8 @@ class DefaultNodeAttachClient {
|
|
|
12787
12788
|
const deadline = Date.now() + this.timeoutMs;
|
|
12788
12789
|
while (Date.now() < deadline) {
|
|
12789
12790
|
// Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
|
|
12790
|
-
if (connector.state !== core.ConnectorState.STARTED &&
|
|
12791
|
+
if (connector.state !== core.ConnectorState.STARTED &&
|
|
12792
|
+
connector.state !== core.ConnectorState.PAUSED) {
|
|
12791
12793
|
let errorMessage = 'Connector closed while waiting for NodeAttachAck';
|
|
12792
12794
|
if (connector.closeCode !== undefined) {
|
|
12793
12795
|
errorMessage += ` (code=${connector.closeCode}`;
|
|
@@ -12806,9 +12808,21 @@ class DefaultNodeAttachClient {
|
|
|
12806
12808
|
if (envelope.frame.type === 'NodeAttachAck') {
|
|
12807
12809
|
return envelope;
|
|
12808
12810
|
}
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12811
|
+
// NodeAttach frames during handshake are expected in multi-agent scenarios
|
|
12812
|
+
// where multiple agents attach concurrently to the same channel
|
|
12813
|
+
if (envelope.frame.type === 'NodeAttach') {
|
|
12814
|
+
logger$W.debug('handshake_ignoring_concurrent_attach', {
|
|
12815
|
+
frame_type: envelope.frame.type,
|
|
12816
|
+
frame_system_id: envelope.frame?.systemId ??
|
|
12817
|
+
'unknown',
|
|
12818
|
+
});
|
|
12819
|
+
}
|
|
12820
|
+
else {
|
|
12821
|
+
// Other unexpected frames are still logged as errors
|
|
12822
|
+
logger$W.error('unexpected_frame_during_handshake', {
|
|
12823
|
+
frame_type: envelope.frame.type,
|
|
12824
|
+
});
|
|
12825
|
+
}
|
|
12812
12826
|
}
|
|
12813
12827
|
await delay(HANDSHAKE_POLL_INTERVAL_MS);
|
|
12814
12828
|
}
|
|
@@ -13527,7 +13541,8 @@ function createFsShim() {
|
|
|
13527
13541
|
else if (options &&
|
|
13528
13542
|
typeof options === 'object' &&
|
|
13529
13543
|
'encoding' in options &&
|
|
13530
|
-
typeof options.encoding ===
|
|
13544
|
+
typeof options.encoding ===
|
|
13545
|
+
'string') {
|
|
13531
13546
|
encoding = options.encoding;
|
|
13532
13547
|
}
|
|
13533
13548
|
const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
|
|
@@ -20460,7 +20475,8 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20460
20475
|
this.listenerRegistered = false;
|
|
20461
20476
|
this.visibilityChangeListenerRegistered = false;
|
|
20462
20477
|
this.channelName =
|
|
20463
|
-
typeof config.channelName === 'string' &&
|
|
20478
|
+
typeof config.channelName === 'string' &&
|
|
20479
|
+
config.channelName.trim().length > 0
|
|
20464
20480
|
? config.channelName.trim()
|
|
20465
20481
|
: DEFAULT_CHANNEL$6;
|
|
20466
20482
|
const preferredCapacity = typeof config.inboxCapacity === 'number' &&
|
|
@@ -20499,7 +20515,8 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20499
20515
|
channel: this.channelName,
|
|
20500
20516
|
connector_id: this.connectorId,
|
|
20501
20517
|
message_type: message && typeof message === 'object'
|
|
20502
|
-
? message.constructor
|
|
20518
|
+
? (message.constructor
|
|
20519
|
+
?.name ?? typeof message)
|
|
20503
20520
|
: typeof message,
|
|
20504
20521
|
has_sender_id: Boolean(message?.senderId),
|
|
20505
20522
|
has_sender_node_id: Boolean(message?.senderNodeId),
|
|
@@ -20508,7 +20525,8 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20508
20525
|
return;
|
|
20509
20526
|
}
|
|
20510
20527
|
const busMessage = message;
|
|
20511
|
-
const senderId = typeof busMessage.senderId === 'string' &&
|
|
20528
|
+
const senderId = typeof busMessage.senderId === 'string' &&
|
|
20529
|
+
busMessage.senderId.length > 0
|
|
20512
20530
|
? busMessage.senderId
|
|
20513
20531
|
: null;
|
|
20514
20532
|
const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
@@ -20759,7 +20777,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20759
20777
|
timestamp: new Date().toISOString(),
|
|
20760
20778
|
});
|
|
20761
20779
|
}
|
|
20762
|
-
if (this.visibilityChangeListenerRegistered &&
|
|
20780
|
+
if (this.visibilityChangeListenerRegistered &&
|
|
20781
|
+
this.visibilityChangeHandler &&
|
|
20782
|
+
typeof document !== 'undefined') {
|
|
20763
20783
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
20764
20784
|
this.visibilityChangeListenerRegistered = false;
|
|
20765
20785
|
this.visibilityChangeHandler = undefined;
|
|
@@ -20776,7 +20796,7 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20776
20796
|
return rawOrEnvelope;
|
|
20777
20797
|
}
|
|
20778
20798
|
_isWildcardTarget() {
|
|
20779
|
-
return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
|
|
20799
|
+
return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
|
|
20780
20800
|
}
|
|
20781
20801
|
_shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
|
|
20782
20802
|
if (this._isWildcardTarget()) {
|
|
@@ -20796,7 +20816,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20796
20816
|
return true;
|
|
20797
20817
|
}
|
|
20798
20818
|
const expectedSender = this.targetNodeId;
|
|
20799
|
-
if (expectedSender &&
|
|
20819
|
+
if (expectedSender &&
|
|
20820
|
+
expectedSender !== '*' &&
|
|
20821
|
+
senderNodeId !== expectedSender) {
|
|
20800
20822
|
logger$G.debug('inpage_message_rejected', {
|
|
20801
20823
|
channel: this.channelName,
|
|
20802
20824
|
connector_id: this.connectorId,
|
|
@@ -21216,8 +21238,8 @@ class CertificateManagerFactory extends factory.AbstractResourceFactory {
|
|
|
21216
21238
|
}
|
|
21217
21239
|
}
|
|
21218
21240
|
|
|
21219
|
-
const DEFAULT_UNCONFIGURED_MESSAGE =
|
|
21220
|
-
const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE =
|
|
21241
|
+
const DEFAULT_UNCONFIGURED_MESSAGE = 'Trust store is not configured. Set FAME_CA_CERTS to a PEM value, a file path, a data URI, or an HTTPS bundle URL.';
|
|
21242
|
+
const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = 'TrustStoreProviderFactory';
|
|
21221
21243
|
class TrustStoreProviderFactory extends factory.AbstractResourceFactory {
|
|
21222
21244
|
createUnconfiguredProvider(reason) {
|
|
21223
21245
|
return new NoopTrustStoreProvider(reason ?? DEFAULT_UNCONFIGURED_MESSAGE);
|
|
@@ -24945,7 +24967,8 @@ class DefaultSecurityManager {
|
|
|
24945
24967
|
const hasSignature = Boolean(envelope.sec?.sig);
|
|
24946
24968
|
if (!hasSignature) {
|
|
24947
24969
|
const nodeSid = node.sid;
|
|
24948
|
-
const envelopeSid = envelope
|
|
24970
|
+
const envelopeSid = envelope
|
|
24971
|
+
.sid;
|
|
24949
24972
|
const isLocalUnsignedSelfEnvelope = localContext.originType === core.DeliveryOriginType.LOCAL &&
|
|
24950
24973
|
typeof nodeSid === 'string' &&
|
|
24951
24974
|
nodeSid.length > 0 &&
|
|
@@ -28225,14 +28248,16 @@ function normalizeInPageConnectionGrant(candidate) {
|
|
|
28225
28248
|
type,
|
|
28226
28249
|
purpose,
|
|
28227
28250
|
};
|
|
28228
|
-
const channelValue = candidate.channelName ??
|
|
28251
|
+
const channelValue = candidate.channelName ??
|
|
28252
|
+
candidate['channel_name'];
|
|
28229
28253
|
if (channelValue !== undefined) {
|
|
28230
28254
|
if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
|
|
28231
28255
|
throw new TypeError('InPageConnectionGrant "channelName" must be a non-empty string when provided');
|
|
28232
28256
|
}
|
|
28233
28257
|
result.channelName = channelValue.trim();
|
|
28234
28258
|
}
|
|
28235
|
-
const inboxValue = candidate.inboxCapacity ??
|
|
28259
|
+
const inboxValue = candidate.inboxCapacity ??
|
|
28260
|
+
candidate['inbox_capacity'];
|
|
28236
28261
|
if (inboxValue !== undefined) {
|
|
28237
28262
|
if (typeof inboxValue !== 'number' ||
|
|
28238
28263
|
!Number.isFinite(inboxValue) ||
|
|
@@ -28748,6 +28773,44 @@ function normalizeRouterOptions(options) {
|
|
|
28748
28773
|
return { welcomeService, prefix };
|
|
28749
28774
|
}
|
|
28750
28775
|
|
|
28776
|
+
/**
|
|
28777
|
+
* Fabric Registry
|
|
28778
|
+
*
|
|
28779
|
+
* Provides a mapping from nodes to their associated fabrics.
|
|
28780
|
+
* This allows agents to retrieve the fabric they were registered on
|
|
28781
|
+
* without relying on the global fabric stack.
|
|
28782
|
+
*/
|
|
28783
|
+
/**
|
|
28784
|
+
* WeakMap to store the node-to-fabric mapping.
|
|
28785
|
+
* Using WeakMap ensures that nodes can be garbage collected
|
|
28786
|
+
* when no longer referenced elsewhere.
|
|
28787
|
+
*/
|
|
28788
|
+
const nodeToFabric = new WeakMap();
|
|
28789
|
+
/**
|
|
28790
|
+
* @internal
|
|
28791
|
+
* Associates a node with its fabric. This should only be called
|
|
28792
|
+
* by fabric implementations when they create or adopt a node.
|
|
28793
|
+
*
|
|
28794
|
+
* @param node - The node to associate
|
|
28795
|
+
* @param fabric - The fabric that owns the node
|
|
28796
|
+
*/
|
|
28797
|
+
function _setFabricForNode(node, fabric) {
|
|
28798
|
+
nodeToFabric.set(node, fabric);
|
|
28799
|
+
}
|
|
28800
|
+
/**
|
|
28801
|
+
* Retrieves the fabric associated with a node.
|
|
28802
|
+
*
|
|
28803
|
+
* This is useful for agents that need to access the fabric they
|
|
28804
|
+
* were registered on, particularly in environments where multiple
|
|
28805
|
+
* fabrics exist (e.g., React with multiple FabricProviders).
|
|
28806
|
+
*
|
|
28807
|
+
* @param node - The node to look up
|
|
28808
|
+
* @returns The fabric associated with the node, or undefined if not found
|
|
28809
|
+
*/
|
|
28810
|
+
function getFabricForNode(node) {
|
|
28811
|
+
return nodeToFabric.get(node);
|
|
28812
|
+
}
|
|
28813
|
+
|
|
28751
28814
|
/**
|
|
28752
28815
|
* Browser-friendly entry point for Naylence Runtime.
|
|
28753
28816
|
*
|
|
@@ -28838,10 +28901,12 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28838
28901
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
28839
28902
|
};
|
|
28840
28903
|
const channelCandidate = record.channelName ?? record['channel_name'];
|
|
28841
|
-
if (typeof channelCandidate === 'string' &&
|
|
28904
|
+
if (typeof channelCandidate === 'string' &&
|
|
28905
|
+
channelCandidate.trim().length > 0) {
|
|
28842
28906
|
config.channelName = channelCandidate.trim();
|
|
28843
28907
|
}
|
|
28844
|
-
const inboxCandidate = record.inboxCapacity ??
|
|
28908
|
+
const inboxCandidate = record.inboxCapacity ??
|
|
28909
|
+
record['inbox_capacity'];
|
|
28845
28910
|
if (typeof inboxCandidate === 'number' &&
|
|
28846
28911
|
Number.isFinite(inboxCandidate) &&
|
|
28847
28912
|
inboxCandidate > 0) {
|
|
@@ -28865,9 +28930,11 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28865
28930
|
throw new Error('BroadcastChannelConnectorFactory requires a configuration');
|
|
28866
28931
|
}
|
|
28867
28932
|
const normalized = this._normalizeConfig(config);
|
|
28868
|
-
const options = (factoryArgs[0] ??
|
|
28933
|
+
const options = (factoryArgs[0] ??
|
|
28934
|
+
{});
|
|
28869
28935
|
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
28870
|
-
const localNodeId = this._normalizeNodeId(options.localNodeId) ??
|
|
28936
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ??
|
|
28937
|
+
normalizedLocalNodeFromConfig;
|
|
28871
28938
|
if (!localNodeId) {
|
|
28872
28939
|
throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
|
|
28873
28940
|
}
|
|
@@ -28892,6 +28959,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28892
28959
|
inboxCapacity,
|
|
28893
28960
|
localNodeId,
|
|
28894
28961
|
initialTargetNodeId: resolvedTarget,
|
|
28962
|
+
passive: normalized.passive,
|
|
28895
28963
|
};
|
|
28896
28964
|
const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
|
|
28897
28965
|
if (options.authorization) {
|
|
@@ -28930,6 +28998,9 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28930
28998
|
if (normalizedLocalNodeId) {
|
|
28931
28999
|
normalized.localNodeId = normalizedLocalNodeId;
|
|
28932
29000
|
}
|
|
29001
|
+
if (typeof candidate.passive === 'boolean') {
|
|
29002
|
+
normalized.passive = candidate.passive;
|
|
29003
|
+
}
|
|
28933
29004
|
if (typeof candidate.flowControl === 'boolean') {
|
|
28934
29005
|
normalized.flowControl = candidate.flowControl;
|
|
28935
29006
|
}
|
|
@@ -29010,7 +29081,9 @@ function normalizeConfig$r(config) {
|
|
|
29010
29081
|
: DEFAULT_CHANNEL$4;
|
|
29011
29082
|
const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
|
|
29012
29083
|
let inboxCapacity = DEFAULT_INBOX_CAPACITY$4;
|
|
29013
|
-
if (typeof rawInbox === 'number' &&
|
|
29084
|
+
if (typeof rawInbox === 'number' &&
|
|
29085
|
+
Number.isFinite(rawInbox) &&
|
|
29086
|
+
rawInbox > 0) {
|
|
29014
29087
|
inboxCapacity = Math.floor(rawInbox);
|
|
29015
29088
|
}
|
|
29016
29089
|
else if (typeof rawInbox === 'string') {
|
|
@@ -29527,7 +29600,8 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29527
29600
|
const normalized = this._normalizeConfig(config);
|
|
29528
29601
|
const options = (factoryArgs[0] ?? {});
|
|
29529
29602
|
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
29530
|
-
const localNodeId = this._normalizeNodeId(options.localNodeId) ??
|
|
29603
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ??
|
|
29604
|
+
normalizedLocalNodeFromConfig;
|
|
29531
29605
|
if (!localNodeId) {
|
|
29532
29606
|
throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
|
|
29533
29607
|
}
|
|
@@ -29677,7 +29751,9 @@ function normalizeConfig$p(config) {
|
|
|
29677
29751
|
: DEFAULT_CHANNEL$2;
|
|
29678
29752
|
const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
|
|
29679
29753
|
let inboxCapacity = DEFAULT_INBOX_CAPACITY$2;
|
|
29680
|
-
if (typeof rawInbox === 'number' &&
|
|
29754
|
+
if (typeof rawInbox === 'number' &&
|
|
29755
|
+
Number.isFinite(rawInbox) &&
|
|
29756
|
+
rawInbox > 0) {
|
|
29681
29757
|
inboxCapacity = Math.floor(rawInbox);
|
|
29682
29758
|
}
|
|
29683
29759
|
else if (typeof rawInbox === 'string') {
|
|
@@ -29705,9 +29781,7 @@ class InPageListenerFactory extends TransportListenerFactory {
|
|
|
29705
29781
|
}
|
|
29706
29782
|
async create(config, ...factoryArgs) {
|
|
29707
29783
|
const normalized = normalizeConfig$p(config);
|
|
29708
|
-
const [{ InPageListener }] = await Promise.all([
|
|
29709
|
-
getInPageListenerModule(),
|
|
29710
|
-
]);
|
|
29784
|
+
const [{ InPageListener }] = await Promise.all([getInPageListenerModule()]);
|
|
29711
29785
|
return new InPageListener({
|
|
29712
29786
|
channelName: normalized.channelName,
|
|
29713
29787
|
inboxCapacity: normalized.inboxCapacity,
|
|
@@ -30617,6 +30691,8 @@ class InProcessFameFabric extends core.FameFabric {
|
|
|
30617
30691
|
this._currentNode = await NodeLikeFactory.createNode(nodeConfig);
|
|
30618
30692
|
this._ownsNode = true;
|
|
30619
30693
|
}
|
|
30694
|
+
// Register this fabric in the registry so agents can look it up
|
|
30695
|
+
_setFabricForNode(this._currentNode, this);
|
|
30620
30696
|
if (this._ownsNode && !this._nodeStarted) {
|
|
30621
30697
|
await this.getRequiredNode().start();
|
|
30622
30698
|
this._nodeStarted = true;
|
|
@@ -32758,19 +32834,23 @@ function normalizeConfig$a(config) {
|
|
|
32758
32834
|
normalized.clientSecretConfig = normalizeSecretSource(clientSecretSource);
|
|
32759
32835
|
}
|
|
32760
32836
|
const audienceCandidate = candidate.audience ?? candidate.aud;
|
|
32761
|
-
if (typeof audienceCandidate === 'string' &&
|
|
32837
|
+
if (typeof audienceCandidate === 'string' &&
|
|
32838
|
+
audienceCandidate.trim().length > 0) {
|
|
32762
32839
|
normalized.audience = audienceCandidate.trim();
|
|
32763
32840
|
}
|
|
32764
32841
|
const codeChallengeMethod = candidate.codeChallengeMethod ?? candidate.code_challenge_method;
|
|
32765
|
-
if (typeof codeChallengeMethod === 'string' &&
|
|
32842
|
+
if (typeof codeChallengeMethod === 'string' &&
|
|
32843
|
+
codeChallengeMethod.trim().length > 0) {
|
|
32766
32844
|
normalized.codeChallengeMethod = codeChallengeMethod.trim();
|
|
32767
32845
|
}
|
|
32768
32846
|
const codeVerifierLength = candidate.codeVerifierLength ?? candidate.code_verifier_length;
|
|
32769
|
-
if (typeof codeVerifierLength === 'number' &&
|
|
32847
|
+
if (typeof codeVerifierLength === 'number' &&
|
|
32848
|
+
Number.isFinite(codeVerifierLength)) {
|
|
32770
32849
|
normalized.codeVerifierLength = codeVerifierLength;
|
|
32771
32850
|
}
|
|
32772
32851
|
const clockSkewSeconds = candidate.clockSkewSeconds ?? candidate.clock_skew_seconds;
|
|
32773
|
-
if (typeof clockSkewSeconds === 'number' &&
|
|
32852
|
+
if (typeof clockSkewSeconds === 'number' &&
|
|
32853
|
+
Number.isFinite(clockSkewSeconds)) {
|
|
32774
32854
|
normalized.clockSkewSeconds = clockSkewSeconds;
|
|
32775
32855
|
}
|
|
32776
32856
|
const loginHintParam = candidate.loginHintParam ?? candidate.login_hint_param;
|
|
@@ -32815,8 +32895,8 @@ class OAuth2PkceTokenProviderFactory extends TokenProviderFactory {
|
|
|
32815
32895
|
options.audience = normalized.audience;
|
|
32816
32896
|
}
|
|
32817
32897
|
if (normalized.codeChallengeMethod) {
|
|
32818
|
-
options.codeChallengeMethod =
|
|
32819
|
-
.toUpperCase();
|
|
32898
|
+
options.codeChallengeMethod =
|
|
32899
|
+
normalized.codeChallengeMethod.toUpperCase();
|
|
32820
32900
|
}
|
|
32821
32901
|
if (normalized.codeVerifierLength) {
|
|
32822
32902
|
options.codeVerifierLength = normalized.codeVerifierLength;
|
|
@@ -34573,14 +34653,14 @@ var eddsaEnvelopeVerifierFactory = /*#__PURE__*/Object.freeze({
|
|
|
34573
34653
|
|
|
34574
34654
|
const FACTORY_META$d = {
|
|
34575
34655
|
base: TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE,
|
|
34576
|
-
key:
|
|
34656
|
+
key: 'NoopTrustStoreProvider',
|
|
34577
34657
|
isDefault: true,
|
|
34578
34658
|
priority: 10,
|
|
34579
34659
|
};
|
|
34580
34660
|
class NoopTrustStoreProviderFactory extends TrustStoreProviderFactory {
|
|
34581
34661
|
constructor() {
|
|
34582
34662
|
super(...arguments);
|
|
34583
|
-
this.type =
|
|
34663
|
+
this.type = 'NoopTrustStoreProvider';
|
|
34584
34664
|
this.isDefault = true;
|
|
34585
34665
|
this.priority = 10;
|
|
34586
34666
|
}
|
|
@@ -36283,9 +36363,7 @@ const defaultGrantSelectionPolicy = new GrantSelectionPolicy();
|
|
|
36283
36363
|
const logger$a = getLogger('naylence.fame.connector.broadcast_channel_listener');
|
|
36284
36364
|
const DEFAULT_CHANNEL$1 = 'naylence-fabric';
|
|
36285
36365
|
const DEFAULT_INBOX_CAPACITY$1 = 2048;
|
|
36286
|
-
const RESPONSE_TYPE_MASK = core.FameResponseType.ACK |
|
|
36287
|
-
core.FameResponseType.REPLY |
|
|
36288
|
-
core.FameResponseType.STREAM;
|
|
36366
|
+
const RESPONSE_TYPE_MASK = core.FameResponseType.ACK | core.FameResponseType.REPLY | core.FameResponseType.STREAM;
|
|
36289
36367
|
const isBrowserEnvironment$2 = () => typeof window !== 'undefined' &&
|
|
36290
36368
|
typeof BroadcastChannel !== 'undefined' &&
|
|
36291
36369
|
typeof MessageEvent !== 'undefined';
|
|
@@ -36499,9 +36577,7 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36499
36577
|
return null;
|
|
36500
36578
|
}
|
|
36501
36579
|
})();
|
|
36502
|
-
if (error instanceof zod.ZodError &&
|
|
36503
|
-
decoded &&
|
|
36504
|
-
decoded.length > 0) {
|
|
36580
|
+
if (error instanceof zod.ZodError && decoded && decoded.length > 0) {
|
|
36505
36581
|
try {
|
|
36506
36582
|
const reparsed = JSON.parse(decoded);
|
|
36507
36583
|
const candidate = reparsed.rtype;
|
|
@@ -36724,11 +36800,19 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36724
36800
|
? Math.floor(initialWindowCandidate)
|
|
36725
36801
|
: undefined;
|
|
36726
36802
|
const initialTargetNodeId = this._normalizeNodeId(targetCandidate) ?? targetSystemId;
|
|
36803
|
+
const passive = typeof passiveCandidate === 'boolean' ? passiveCandidate : true;
|
|
36804
|
+
logger$a.debug('broadcast_channel_listener_building_connector_config', {
|
|
36805
|
+
system_id: systemId,
|
|
36806
|
+
channel_name: channelName,
|
|
36807
|
+
passive,
|
|
36808
|
+
has_base_config: !!baseConfig,
|
|
36809
|
+
passive_candidate: passiveCandidate,
|
|
36810
|
+
});
|
|
36727
36811
|
return {
|
|
36728
36812
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
36729
36813
|
channelName,
|
|
36730
36814
|
inboxCapacity,
|
|
36731
|
-
passive
|
|
36815
|
+
passive,
|
|
36732
36816
|
initialWindow,
|
|
36733
36817
|
localNodeId,
|
|
36734
36818
|
initialTargetNodeId,
|
|
@@ -37479,7 +37563,9 @@ class InPageListener extends TransportListener {
|
|
|
37479
37563
|
typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
|
|
37480
37564
|
? channelCandidate.trim()
|
|
37481
37565
|
: DEFAULT_CHANNEL;
|
|
37482
|
-
const normalizedCapacity = typeof inboxCandidate === 'number' &&
|
|
37566
|
+
const normalizedCapacity = typeof inboxCandidate === 'number' &&
|
|
37567
|
+
Number.isFinite(inboxCandidate) &&
|
|
37568
|
+
inboxCandidate > 0
|
|
37483
37569
|
? Math.floor(inboxCandidate)
|
|
37484
37570
|
: DEFAULT_INBOX_CAPACITY;
|
|
37485
37571
|
this._inboxCapacity = normalizedCapacity;
|
|
@@ -37754,7 +37840,8 @@ class InPageListener extends TransportListener {
|
|
|
37754
37840
|
if (grant.type === INPAGE_CONNECTION_GRANT_TYPE) {
|
|
37755
37841
|
return inPageGrantToConnectorConfig(grant);
|
|
37756
37842
|
}
|
|
37757
|
-
if (typeof grant
|
|
37843
|
+
if (typeof grant
|
|
37844
|
+
?.toConnectorConfig === 'function') {
|
|
37758
37845
|
return grant.toConnectorConfig();
|
|
37759
37846
|
}
|
|
37760
37847
|
throw new Error(`Unsupported grant type: ${grant.type}`);
|
|
@@ -39292,8 +39379,7 @@ function normalizeOptions$2(raw) {
|
|
|
39292
39379
|
const scopes = normalizeScopes(camel.scopes) ??
|
|
39293
39380
|
normalizeScopes(snake.scopes ?? snake.scope) ??
|
|
39294
39381
|
DEFAULT_SCOPES.slice();
|
|
39295
|
-
const audience = coerceString(camel.audience) ??
|
|
39296
|
-
coerceString(snake.audience ?? snake.aud);
|
|
39382
|
+
const audience = coerceString(camel.audience) ?? coerceString(snake.audience ?? snake.aud);
|
|
39297
39383
|
const fetchImpl = (camel.fetchImpl ?? snake.fetch_impl);
|
|
39298
39384
|
const clockSkewSeconds = coerceNumber(camel.clockSkewSeconds) ??
|
|
39299
39385
|
coerceNumber(snake.clock_skew_seconds) ??
|
|
@@ -40997,6 +41083,7 @@ exports.formatTimestamp = formatTimestamp;
|
|
|
40997
41083
|
exports.formatTimestampForConsole = formatTimestampForConsole$1;
|
|
40998
41084
|
exports.frameDigest = frameDigest;
|
|
40999
41085
|
exports.getCurrentEnvelope = getCurrentEnvelope;
|
|
41086
|
+
exports.getFabricForNode = getFabricForNode;
|
|
41000
41087
|
exports.getFameRoot = getFameRoot;
|
|
41001
41088
|
exports.getKeyProvider = getKeyProvider;
|
|
41002
41089
|
exports.getKeyStore = getKeyStore;
|
|
@@ -41063,6 +41150,7 @@ exports.registerRuntimeFactories = registerRuntimeFactories;
|
|
|
41063
41150
|
exports.requireCryptoSupport = requireCryptoSupport;
|
|
41064
41151
|
exports.retryWithBackoff = retryWithBackoff;
|
|
41065
41152
|
exports.safeColor = safeColor;
|
|
41153
|
+
exports.safeImport = safeImport;
|
|
41066
41154
|
exports.sealedDecrypt = sealedDecrypt;
|
|
41067
41155
|
exports.sealedEncrypt = sealedEncrypt;
|
|
41068
41156
|
exports.secureDigest = secureDigest;
|