@naylence/runtime 0.3.6 → 0.3.7

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.
Files changed (71) hide show
  1. package/dist/browser/index.cjs +220 -172
  2. package/dist/browser/index.mjs +220 -173
  3. package/dist/cjs/_env-shim.js +2 -1
  4. package/dist/cjs/naylence/fame/config/extended-fame-config.js +2 -1
  5. package/dist/cjs/naylence/fame/connector/broadcast-channel-connector-factory.js +12 -4
  6. package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +14 -6
  7. package/dist/cjs/naylence/fame/connector/broadcast-channel-listener-factory.js +3 -1
  8. package/dist/cjs/naylence/fame/connector/broadcast-channel-listener.js +11 -7
  9. package/dist/cjs/naylence/fame/connector/index.js +2 -1
  10. package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +2 -1
  11. package/dist/cjs/naylence/fame/connector/inpage-connector.js +13 -6
  12. package/dist/cjs/naylence/fame/connector/inpage-listener-factory.js +4 -4
  13. package/dist/cjs/naylence/fame/connector/inpage-listener.js +5 -2
  14. package/dist/cjs/naylence/fame/delivery/default-delivery-tracker.js +4 -62
  15. package/dist/cjs/naylence/fame/grants/broadcast-channel-connection-grant.js +6 -3
  16. package/dist/cjs/naylence/fame/grants/inpage-connection-grant.js +4 -2
  17. package/dist/cjs/naylence/fame/http/oauth2-token-router.js +9 -9
  18. package/dist/cjs/naylence/fame/node/admission/default-node-attach-client.js +34 -5
  19. package/dist/cjs/naylence/fame/node/upstream-session-manager.js +40 -8
  20. package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.js +10 -6
  21. package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider.js +1 -2
  22. package/dist/cjs/naylence/fame/security/default-security-manager.js +2 -1
  23. package/dist/cjs/naylence/fame/security/trust-store/noop-trust-store-provider-factory.js +2 -2
  24. package/dist/cjs/naylence/fame/security/trust-store/trust-store-provider-factory.js +2 -2
  25. package/dist/cjs/naylence/fame/util/index.js +3 -1
  26. package/dist/cjs/node.js +4 -1
  27. package/dist/cjs/version.js +2 -2
  28. package/dist/esm/_env-shim.js +2 -1
  29. package/dist/esm/browser.js +2 -2
  30. package/dist/esm/naylence/fame/config/extended-fame-config.js +2 -1
  31. package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +12 -4
  32. package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +14 -6
  33. package/dist/esm/naylence/fame/connector/broadcast-channel-listener-factory.js +3 -1
  34. package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +11 -7
  35. package/dist/esm/naylence/fame/connector/index.js +2 -2
  36. package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +2 -1
  37. package/dist/esm/naylence/fame/connector/inpage-connector.js +13 -6
  38. package/dist/esm/naylence/fame/connector/inpage-listener-factory.js +4 -4
  39. package/dist/esm/naylence/fame/connector/inpage-listener.js +5 -2
  40. package/dist/esm/naylence/fame/delivery/default-delivery-tracker.js +4 -62
  41. package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +6 -3
  42. package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +4 -2
  43. package/dist/esm/naylence/fame/http/oauth2-token-router.js +9 -9
  44. package/dist/esm/naylence/fame/node/admission/default-node-attach-client.js +34 -5
  45. package/dist/esm/naylence/fame/node/upstream-session-manager.js +40 -8
  46. package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider-factory.js +10 -6
  47. package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider.js +1 -2
  48. package/dist/esm/naylence/fame/security/default-security-manager.js +2 -1
  49. package/dist/esm/naylence/fame/security/index.js +1 -1
  50. package/dist/esm/naylence/fame/security/trust-store/noop-trust-store-provider-factory.js +3 -3
  51. package/dist/esm/naylence/fame/security/trust-store/trust-store-provider-factory.js +3 -3
  52. package/dist/esm/naylence/fame/util/index.js +1 -0
  53. package/dist/esm/node.js +2 -1
  54. package/dist/esm/version.js +2 -2
  55. package/dist/node/index.cjs +218 -171
  56. package/dist/node/index.mjs +218 -172
  57. package/dist/node/node.cjs +184 -136
  58. package/dist/node/node.mjs +183 -137
  59. package/dist/types/browser.d.ts +2 -2
  60. package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +1 -0
  61. package/dist/types/naylence/fame/connector/index.d.ts +3 -3
  62. package/dist/types/naylence/fame/delivery/default-delivery-tracker.d.ts +0 -6
  63. package/dist/types/naylence/fame/node/admission/default-node-attach-client.d.ts +1 -0
  64. package/dist/types/naylence/fame/security/index.d.ts +1 -1
  65. package/dist/types/naylence/fame/security/trust-store/noop-trust-store-provider-factory.d.ts +3 -3
  66. package/dist/types/naylence/fame/security/trust-store/trust-store-provider-factory.d.ts +4 -4
  67. package/dist/types/naylence/fame/security/trust-store/trust-store-provider.d.ts +5 -5
  68. package/dist/types/naylence/fame/util/index.d.ts +1 -0
  69. package/dist/types/node.d.ts +2 -1
  70. package/dist/types/version.d.ts +1 -1
  71. package/package.json +1 -1
@@ -13,12 +13,12 @@ import fastify from 'fastify';
13
13
  import websocketPlugin from '@fastify/websocket';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.6
16
+ // Generated from package.json version: 0.3.7
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.6';
21
+ const VERSION = '0.3.7';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -2247,6 +2247,50 @@ function validateKeyCorrelationTtlSec(ttlSec) {
2247
2247
  });
2248
2248
  }
2249
2249
 
2250
+ function isModuleNotFoundError(error) {
2251
+ if (!(error instanceof Error)) {
2252
+ return false;
2253
+ }
2254
+ const message = error.message || '';
2255
+ if (message.includes('Cannot find module') ||
2256
+ message.includes('ERR_MODULE_NOT_FOUND') ||
2257
+ message.includes('MODULE_NOT_FOUND')) {
2258
+ return true;
2259
+ }
2260
+ const code = error.code;
2261
+ if (typeof code === 'string') {
2262
+ return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
2263
+ }
2264
+ return false;
2265
+ }
2266
+ /**
2267
+ * Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
2268
+ */
2269
+ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
2270
+ const options = typeof dependencyNameOrOptions === 'string'
2271
+ ? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
2272
+ : dependencyNameOrOptions;
2273
+ const dependencyName = options.dependencyName;
2274
+ try {
2275
+ return await loader();
2276
+ }
2277
+ catch (error) {
2278
+ if (isModuleNotFoundError(error)) {
2279
+ const message = options.helpMessage ??
2280
+ `Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
2281
+ const enrichedError = new Error(message);
2282
+ try {
2283
+ enrichedError.cause = error;
2284
+ }
2285
+ catch {
2286
+ // Ignore environments that do not support attaching a cause.
2287
+ }
2288
+ throw enrichedError;
2289
+ }
2290
+ throw error;
2291
+ }
2292
+ }
2293
+
2250
2294
  /**
2251
2295
  * flow_controller.ts - credit window management with cooperative back-pressure.
2252
2296
  *
@@ -3451,50 +3495,6 @@ function normalizeSecretSource(value) {
3451
3495
  return SecretSource.normalize(value);
3452
3496
  }
3453
3497
 
3454
- function isModuleNotFoundError(error) {
3455
- if (!(error instanceof Error)) {
3456
- return false;
3457
- }
3458
- const message = error.message || '';
3459
- if (message.includes('Cannot find module') ||
3460
- message.includes('ERR_MODULE_NOT_FOUND') ||
3461
- message.includes('MODULE_NOT_FOUND')) {
3462
- return true;
3463
- }
3464
- const code = error.code;
3465
- if (typeof code === 'string') {
3466
- return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
3467
- }
3468
- return false;
3469
- }
3470
- /**
3471
- * Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
3472
- */
3473
- async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
3474
- const options = typeof dependencyNameOrOptions === 'string'
3475
- ? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
3476
- : dependencyNameOrOptions;
3477
- const dependencyName = options.dependencyName;
3478
- try {
3479
- return await loader();
3480
- }
3481
- catch (error) {
3482
- if (isModuleNotFoundError(error)) {
3483
- const message = options.helpMessage ??
3484
- `Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
3485
- const enrichedError = new Error(message);
3486
- try {
3487
- enrichedError.cause = error;
3488
- }
3489
- catch {
3490
- // Ignore environments that do not support attaching a cause.
3491
- }
3492
- throw enrichedError;
3493
- }
3494
- throw error;
3495
- }
3496
- }
3497
-
3498
3498
  const indexedDBConfigSchema = z
3499
3499
  .object({
3500
3500
  type: z
@@ -7090,9 +7090,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
7090
7090
  this.ackDoneSince = new Map();
7091
7091
  this.replyDoneSince = new Map();
7092
7092
  this.pendingAckDispatches = new Set();
7093
- this.recentlyHandled = new Map();
7094
- this.recentlyHandledOrder = [];
7095
- this.recentlyHandledTtlMs = 60000;
7096
7093
  this.isPreparingToStop = false;
7097
7094
  this.shutdownRequestedAtMs = null;
7098
7095
  this.shutdownRetryGraceMs = 1000;
@@ -7314,22 +7311,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
7314
7311
  }
7315
7312
  }
7316
7313
  else {
7317
- const wasRecentlyHandled = await this.lock.runExclusive(async () => this.wasRecentlyHandled(envelope.id));
7318
- if (wasRecentlyHandled) {
7319
- logger$12.debug('tracker_duplicate_envelope_recently_handled', {
7320
- envp_id: envelope.id,
7321
- });
7322
- return new TrackedEnvelope({
7323
- timeoutAtMs: 0,
7324
- overallTimeoutAtMs: 0,
7325
- expectedResponseType: envelope.rtype ?? FameResponseType.NONE,
7326
- createdAtMs: Date.now(),
7327
- status: EnvelopeStatus.HANDLED,
7328
- mailboxType: MailboxType.INBOX,
7329
- originalEnvelope: envelope,
7330
- serviceName: inboxName,
7331
- });
7332
- }
7333
7314
  tracked = new TrackedEnvelope({
7334
7315
  timeoutAtMs: 0,
7335
7316
  overallTimeoutAtMs: 0,
@@ -7351,12 +7332,8 @@ class DefaultDeliveryTracker extends TaskSpawner {
7351
7332
  async onEnvelopeHandled(envelope) {
7352
7333
  const inbox = this.ensureInbox();
7353
7334
  envelope.status = EnvelopeStatus.HANDLED;
7335
+ // Delete the envelope from inbox to prevent growth
7354
7336
  await inbox.delete(envelope.originalEnvelope.id);
7355
- await this.lock.runExclusive(async () => {
7356
- this.markRecentlyHandled(envelope.originalEnvelope.id);
7357
- });
7358
- // Preserve handled envelope to prevent duplicate redelivery during shutdown drains.
7359
- // await inbox.set(envelope.originalEnvelope.id, envelope);
7360
7337
  }
7361
7338
  async onEnvelopeHandleFailed(inboxName, envelope, context, error, isFinalFailure = false) {
7362
7339
  const inbox = this.ensureInbox();
@@ -7571,9 +7548,9 @@ class DefaultDeliveryTracker extends TaskSpawner {
7571
7548
  });
7572
7549
  await this.markDoneSince(this.replyFutures, trackedEnvelope.originalEnvelope.id, this.replyDoneSince);
7573
7550
  await this.markDoneSince(this.ackFutures, trackedEnvelope.originalEnvelope.id, this.ackDoneSince);
7574
- if (envelope.rtype && Boolean(envelope.rtype & FameResponseType.ACK)) {
7575
- await this.sendAck(envelope);
7576
- }
7551
+ // Note: ACK is already sent in onCorrelatedMessage (lines 655-657)
7552
+ // when the reply envelope is first delivered. No need to send it again here.
7553
+ // Removing this duplicate sendAck call fixes the duplicate DeliveryAck bug.
7577
7554
  for (const handler of this.eventHandlers) {
7578
7555
  await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
7579
7556
  }
@@ -7723,8 +7700,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
7723
7700
  }
7724
7701
  this.streamDone.clear();
7725
7702
  this.correlationToEnvelope.clear();
7726
- this.recentlyHandled.clear();
7727
- this.recentlyHandledOrder.length = 0;
7728
7703
  return values;
7729
7704
  });
7730
7705
  for (const timer of timers) {
@@ -8306,39 +8281,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
8306
8281
  this.pendingAckDispatches.delete(ackDispatch);
8307
8282
  }
8308
8283
  }
8309
- markRecentlyHandled(envelopeId) {
8310
- const now = Date.now();
8311
- this.recentlyHandled.set(envelopeId, now);
8312
- this.recentlyHandledOrder.push(envelopeId);
8313
- this.trimRecentlyHandled(now);
8314
- }
8315
- wasRecentlyHandled(envelopeId) {
8316
- const now = Date.now();
8317
- const timestamp = this.recentlyHandled.get(envelopeId);
8318
- if (timestamp === undefined) {
8319
- return false;
8320
- }
8321
- if (now - timestamp > this.recentlyHandledTtlMs) {
8322
- this.recentlyHandled.delete(envelopeId);
8323
- return false;
8324
- }
8325
- return true;
8326
- }
8327
- trimRecentlyHandled(now) {
8328
- while (this.recentlyHandledOrder.length > 0) {
8329
- const candidate = this.recentlyHandledOrder[0];
8330
- const timestamp = this.recentlyHandled.get(candidate);
8331
- if (timestamp === undefined) {
8332
- this.recentlyHandledOrder.shift();
8333
- continue;
8334
- }
8335
- if (now - timestamp <= this.recentlyHandledTtlMs) {
8336
- break;
8337
- }
8338
- this.recentlyHandled.delete(candidate);
8339
- this.recentlyHandledOrder.shift();
8340
- }
8341
- }
8342
8284
  getShutdownRetryDeferDelay(nowMs) {
8343
8285
  if (!this.isPreparingToStop || this.shutdownRequestedAtMs === null) {
8344
8286
  return null;
@@ -9832,7 +9774,8 @@ const ensureBroadcastEnvironment = () => {
9832
9774
  };
9833
9775
  let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAsyncConnector {
9834
9776
  static generateConnectorId() {
9835
- const globalCrypto = globalThis.crypto;
9777
+ const globalCrypto = globalThis
9778
+ .crypto;
9836
9779
  if (globalCrypto?.randomUUID) {
9837
9780
  return globalCrypto.randomUUID();
9838
9781
  }
@@ -9887,7 +9830,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9887
9830
  this.listenerRegistered = false;
9888
9831
  this.visibilityChangeListenerRegistered = false;
9889
9832
  this.channelName =
9890
- typeof config.channelName === 'string' && config.channelName.trim().length > 0
9833
+ typeof config.channelName === 'string' &&
9834
+ config.channelName.trim().length > 0
9891
9835
  ? config.channelName.trim()
9892
9836
  : DEFAULT_CHANNEL$7;
9893
9837
  const preferredCapacity = typeof config.inboxCapacity === 'number' &&
@@ -9911,6 +9855,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9911
9855
  local_node_id: this.localNodeId,
9912
9856
  target_node_id: this.targetNodeId ?? null,
9913
9857
  inbox_capacity: preferredCapacity,
9858
+ passive: config.passive ?? false,
9914
9859
  timestamp: new Date().toISOString(),
9915
9860
  });
9916
9861
  this.onMsg = (event) => {
@@ -9928,7 +9873,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9928
9873
  channel: this.channelName,
9929
9874
  connector_id: this.connectorId,
9930
9875
  message_type: message && typeof message === 'object'
9931
- ? message.constructor?.name ?? typeof message
9876
+ ? (message.constructor
9877
+ ?.name ?? typeof message)
9932
9878
  : typeof message,
9933
9879
  has_sender_id: Boolean(message?.senderId),
9934
9880
  has_sender_node_id: Boolean(message?.senderNodeId),
@@ -10158,7 +10104,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10158
10104
  timestamp: new Date().toISOString(),
10159
10105
  });
10160
10106
  }
10161
- if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
10107
+ if (this.visibilityChangeListenerRegistered &&
10108
+ this.visibilityChangeHandler &&
10109
+ typeof document !== 'undefined') {
10162
10110
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
10163
10111
  this.visibilityChangeListenerRegistered = false;
10164
10112
  this.visibilityChangeHandler = undefined;
@@ -10186,7 +10134,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10186
10134
  return rawOrEnvelope;
10187
10135
  }
10188
10136
  _isWildcardTarget() {
10189
- return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
10137
+ return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
10190
10138
  }
10191
10139
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
10192
10140
  if (this._isWildcardTarget()) {
@@ -10206,7 +10154,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10206
10154
  return true;
10207
10155
  }
10208
10156
  const expectedSender = this.targetNodeId;
10209
- if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
10157
+ if (expectedSender &&
10158
+ expectedSender !== '*' &&
10159
+ senderNodeId !== expectedSender) {
10210
10160
  logger$_.debug('broadcast_channel_message_rejected', {
10211
10161
  channel: this.channelName,
10212
10162
  connector_id: this.connectorId,
@@ -10425,14 +10375,16 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10425
10375
  type,
10426
10376
  purpose,
10427
10377
  };
10428
- const channelValue = candidate.channelName ?? candidate['channel_name'];
10378
+ const channelValue = candidate.channelName ??
10379
+ candidate['channel_name'];
10429
10380
  if (channelValue !== undefined) {
10430
10381
  if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
10431
10382
  throw new TypeError('BroadcastChannelConnectionGrant "channelName" must be a non-empty string when provided');
10432
10383
  }
10433
10384
  result.channelName = channelValue.trim();
10434
10385
  }
10435
- const inboxValue = candidate.inboxCapacity ?? candidate['inbox_capacity'];
10386
+ const inboxValue = candidate.inboxCapacity ??
10387
+ candidate['inbox_capacity'];
10436
10388
  if (inboxValue !== undefined) {
10437
10389
  if (typeof inboxValue !== 'number' ||
10438
10390
  !Number.isFinite(inboxValue) ||
@@ -10441,7 +10393,8 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10441
10393
  }
10442
10394
  result.inboxCapacity = Math.floor(inboxValue);
10443
10395
  }
10444
- const windowValue = candidate.initialWindow ?? candidate['initial_window'];
10396
+ const windowValue = candidate.initialWindow ??
10397
+ candidate['initial_window'];
10445
10398
  if (windowValue !== undefined) {
10446
10399
  if (typeof windowValue !== 'number' ||
10447
10400
  !Number.isFinite(windowValue) ||
@@ -10778,25 +10731,56 @@ class UpstreamSessionManager extends TaskSpawner {
10778
10731
  await connector.start(this.wrappedHandler);
10779
10732
  this.connector = connector;
10780
10733
  const callbackGrants = this.node.gatherSupportedCallbackGrants();
10734
+ logger$Z.debug('callback_grants_before_augmentation', {
10735
+ count: callbackGrants.length,
10736
+ types: callbackGrants.map((g) => g.type),
10737
+ });
10738
+ // Check if we should create a broadcast callback grant before processing connection grants
10739
+ // This prevents adding duplicate broadcast grants
10740
+ const shouldAddBroadcastGrant = this.shouldAdvertiseBroadcastGrant(grant, callbackGrants);
10741
+ const broadcastCallbackGrant = shouldAddBroadcastGrant
10742
+ ? this.createBroadcastCallbackGrant(grant)
10743
+ : null;
10744
+ logger$Z.debug('broadcast_callback_grant_check', {
10745
+ should_add: shouldAddBroadcastGrant,
10746
+ grant_created: !!broadcastCallbackGrant,
10747
+ });
10781
10748
  // Include admission client's connection grants as callback grants
10782
10749
  // This ensures DirectAdmissionClient grants are available for grant selection
10783
- if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
10750
+ if (welcome.frame.connectionGrants &&
10751
+ Array.isArray(welcome.frame.connectionGrants)) {
10784
10752
  for (const grant of welcome.frame.connectionGrants) {
10785
10753
  if (grant && typeof grant === 'object') {
10786
10754
  // Avoid duplicates by checking if grant already exists
10787
- const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
10755
+ const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
10788
10756
  if (!isDuplicate) {
10789
10757
  callbackGrants.push(grant);
10758
+ logger$Z.debug('added_connection_grant_as_callback', {
10759
+ type: grant.type,
10760
+ });
10761
+ }
10762
+ else {
10763
+ logger$Z.debug('skipped_duplicate_connection_grant', {
10764
+ type: grant.type,
10765
+ });
10790
10766
  }
10791
10767
  }
10792
10768
  }
10793
10769
  }
10794
- if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
10795
- const augmented = this.createBroadcastCallbackGrant(grant);
10796
- if (augmented) {
10797
- callbackGrants.push(augmented);
10798
- }
10770
+ // Add broadcast grant after connection grants to ensure we don't duplicate
10771
+ // any broadcast grants that may have been in connectionGrants
10772
+ if (broadcastCallbackGrant &&
10773
+ this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
10774
+ callbackGrants.push(broadcastCallbackGrant);
10775
+ logger$Z.debug('added_broadcast_callback_grant');
10799
10776
  }
10777
+ else if (broadcastCallbackGrant) {
10778
+ logger$Z.debug('skipped_duplicate_broadcast_callback_grant');
10779
+ }
10780
+ logger$Z.debug('callback_grants_after_augmentation', {
10781
+ count: callbackGrants.length,
10782
+ types: callbackGrants.map((g) => g.type),
10783
+ });
10800
10784
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
10801
10785
  this.targetSystemId = attachInfo.targetSystemId ?? null;
10802
10786
  if (this.targetSystemId) {
@@ -11037,7 +11021,8 @@ class UpstreamSessionManager extends TaskSpawner {
11037
11021
  continue;
11038
11022
  }
11039
11023
  // Reset ack time if just resumed from pause (prevents immediate timeout)
11040
- if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
11024
+ if (previousState === ConnectorState.PAUSED &&
11025
+ currentState === ConnectorState.STARTED) {
11041
11026
  logger$Z.debug('connector_just_resumed_resetting_ack_time', {
11042
11027
  previous_state: previousState,
11043
11028
  current_state: currentState,
@@ -12594,15 +12579,30 @@ class DefaultNodeAttachClient {
12594
12579
  constructor(options = {}) {
12595
12580
  this.buffer = [];
12596
12581
  this.inHandshake = false;
12582
+ this.expectedSystemId = null;
12597
12583
  this.timeoutMs = options.timeoutMs ?? 10000;
12598
12584
  this.attachmentKeyValidator = options.attachmentKeyValidator;
12599
12585
  this.replicaStickinessManager = options.replicaStickinessManager ?? null;
12600
12586
  }
12601
12587
  async attach(node, originType, connector, welcomeFrame, finalHandler, keys, callbackGrants) {
12602
12588
  this.inHandshake = true;
12589
+ this.expectedSystemId = welcomeFrame.systemId;
12603
12590
  const interimHandler = async (envelope, context) => {
12604
12591
  if (this.inHandshake) {
12605
- this.buffer.push(envelope);
12592
+ // Filter: only buffer frames related to our systemId or frames without systemId info
12593
+ const frameSystemId = envelope.frame
12594
+ ?.systemId;
12595
+ if (!frameSystemId || frameSystemId === this.expectedSystemId) {
12596
+ this.buffer.push(envelope);
12597
+ }
12598
+ else {
12599
+ // Silently ignore frames from other agents during concurrent handshakes
12600
+ logger$W.debug('handshake_ignoring_frame_from_different_system', {
12601
+ frame_type: envelope.frame.type,
12602
+ frame_system_id: frameSystemId,
12603
+ expected_system_id: this.expectedSystemId,
12604
+ });
12605
+ }
12606
12606
  return null;
12607
12607
  }
12608
12608
  return finalHandler(envelope, context);
@@ -12729,6 +12729,7 @@ class DefaultNodeAttachClient {
12729
12729
  parent_id: ackFrame.targetSystemId,
12730
12730
  });
12731
12731
  this.inHandshake = false;
12732
+ this.expectedSystemId = null;
12732
12733
  await connector.replaceHandler(finalHandler);
12733
12734
  while (this.buffer.length > 0) {
12734
12735
  const bufferedEnvelope = this.buffer.shift();
@@ -12786,7 +12787,8 @@ class DefaultNodeAttachClient {
12786
12787
  const deadline = Date.now() + this.timeoutMs;
12787
12788
  while (Date.now() < deadline) {
12788
12789
  // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
12789
- if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
12790
+ if (connector.state !== ConnectorState.STARTED &&
12791
+ connector.state !== ConnectorState.PAUSED) {
12790
12792
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
12791
12793
  if (connector.closeCode !== undefined) {
12792
12794
  errorMessage += ` (code=${connector.closeCode}`;
@@ -12805,9 +12807,21 @@ class DefaultNodeAttachClient {
12805
12807
  if (envelope.frame.type === 'NodeAttachAck') {
12806
12808
  return envelope;
12807
12809
  }
12808
- logger$W.error('unexpected_frame_during_handshake', {
12809
- frame_type: envelope.frame.type,
12810
- });
12810
+ // NodeAttach frames during handshake are expected in multi-agent scenarios
12811
+ // where multiple agents attach concurrently to the same channel
12812
+ if (envelope.frame.type === 'NodeAttach') {
12813
+ logger$W.debug('handshake_ignoring_concurrent_attach', {
12814
+ frame_type: envelope.frame.type,
12815
+ frame_system_id: envelope.frame?.systemId ??
12816
+ 'unknown',
12817
+ });
12818
+ }
12819
+ else {
12820
+ // Other unexpected frames are still logged as errors
12821
+ logger$W.error('unexpected_frame_during_handshake', {
12822
+ frame_type: envelope.frame.type,
12823
+ });
12824
+ }
12811
12825
  }
12812
12826
  await delay(HANDSHAKE_POLL_INTERVAL_MS);
12813
12827
  }
@@ -13526,7 +13540,8 @@ function createFsShim() {
13526
13540
  else if (options &&
13527
13541
  typeof options === 'object' &&
13528
13542
  'encoding' in options &&
13529
- typeof options.encoding === 'string') {
13543
+ typeof options.encoding ===
13544
+ 'string') {
13530
13545
  encoding = options.encoding;
13531
13546
  }
13532
13547
  const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
@@ -20459,7 +20474,8 @@ class InPageConnector extends BaseAsyncConnector {
20459
20474
  this.listenerRegistered = false;
20460
20475
  this.visibilityChangeListenerRegistered = false;
20461
20476
  this.channelName =
20462
- typeof config.channelName === 'string' && config.channelName.trim().length > 0
20477
+ typeof config.channelName === 'string' &&
20478
+ config.channelName.trim().length > 0
20463
20479
  ? config.channelName.trim()
20464
20480
  : DEFAULT_CHANNEL$6;
20465
20481
  const preferredCapacity = typeof config.inboxCapacity === 'number' &&
@@ -20498,7 +20514,8 @@ class InPageConnector extends BaseAsyncConnector {
20498
20514
  channel: this.channelName,
20499
20515
  connector_id: this.connectorId,
20500
20516
  message_type: message && typeof message === 'object'
20501
- ? message.constructor?.name ?? typeof message
20517
+ ? (message.constructor
20518
+ ?.name ?? typeof message)
20502
20519
  : typeof message,
20503
20520
  has_sender_id: Boolean(message?.senderId),
20504
20521
  has_sender_node_id: Boolean(message?.senderNodeId),
@@ -20507,7 +20524,8 @@ class InPageConnector extends BaseAsyncConnector {
20507
20524
  return;
20508
20525
  }
20509
20526
  const busMessage = message;
20510
- const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
20527
+ const senderId = typeof busMessage.senderId === 'string' &&
20528
+ busMessage.senderId.length > 0
20511
20529
  ? busMessage.senderId
20512
20530
  : null;
20513
20531
  const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
@@ -20758,7 +20776,9 @@ class InPageConnector extends BaseAsyncConnector {
20758
20776
  timestamp: new Date().toISOString(),
20759
20777
  });
20760
20778
  }
20761
- if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
20779
+ if (this.visibilityChangeListenerRegistered &&
20780
+ this.visibilityChangeHandler &&
20781
+ typeof document !== 'undefined') {
20762
20782
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
20763
20783
  this.visibilityChangeListenerRegistered = false;
20764
20784
  this.visibilityChangeHandler = undefined;
@@ -20775,7 +20795,7 @@ class InPageConnector extends BaseAsyncConnector {
20775
20795
  return rawOrEnvelope;
20776
20796
  }
20777
20797
  _isWildcardTarget() {
20778
- return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
20798
+ return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
20779
20799
  }
20780
20800
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
20781
20801
  if (this._isWildcardTarget()) {
@@ -20795,7 +20815,9 @@ class InPageConnector extends BaseAsyncConnector {
20795
20815
  return true;
20796
20816
  }
20797
20817
  const expectedSender = this.targetNodeId;
20798
- if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
20818
+ if (expectedSender &&
20819
+ expectedSender !== '*' &&
20820
+ senderNodeId !== expectedSender) {
20799
20821
  logger$G.debug('inpage_message_rejected', {
20800
20822
  channel: this.channelName,
20801
20823
  connector_id: this.connectorId,
@@ -21215,8 +21237,8 @@ class CertificateManagerFactory extends AbstractResourceFactory {
21215
21237
  }
21216
21238
  }
21217
21239
 
21218
- 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.";
21219
- const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = "TrustStoreProviderFactory";
21240
+ 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.';
21241
+ const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = 'TrustStoreProviderFactory';
21220
21242
  class TrustStoreProviderFactory extends AbstractResourceFactory {
21221
21243
  createUnconfiguredProvider(reason) {
21222
21244
  return new NoopTrustStoreProvider(reason ?? DEFAULT_UNCONFIGURED_MESSAGE);
@@ -24944,7 +24966,8 @@ class DefaultSecurityManager {
24944
24966
  const hasSignature = Boolean(envelope.sec?.sig);
24945
24967
  if (!hasSignature) {
24946
24968
  const nodeSid = node.sid;
24947
- const envelopeSid = envelope.sid;
24969
+ const envelopeSid = envelope
24970
+ .sid;
24948
24971
  const isLocalUnsignedSelfEnvelope = localContext.originType === DeliveryOriginType.LOCAL &&
24949
24972
  typeof nodeSid === 'string' &&
24950
24973
  nodeSid.length > 0 &&
@@ -28224,14 +28247,16 @@ function normalizeInPageConnectionGrant(candidate) {
28224
28247
  type,
28225
28248
  purpose,
28226
28249
  };
28227
- const channelValue = candidate.channelName ?? candidate['channel_name'];
28250
+ const channelValue = candidate.channelName ??
28251
+ candidate['channel_name'];
28228
28252
  if (channelValue !== undefined) {
28229
28253
  if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
28230
28254
  throw new TypeError('InPageConnectionGrant "channelName" must be a non-empty string when provided');
28231
28255
  }
28232
28256
  result.channelName = channelValue.trim();
28233
28257
  }
28234
- const inboxValue = candidate.inboxCapacity ?? candidate['inbox_capacity'];
28258
+ const inboxValue = candidate.inboxCapacity ??
28259
+ candidate['inbox_capacity'];
28235
28260
  if (inboxValue !== undefined) {
28236
28261
  if (typeof inboxValue !== 'number' ||
28237
28262
  !Number.isFinite(inboxValue) ||
@@ -28837,10 +28862,12 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28837
28862
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28838
28863
  };
28839
28864
  const channelCandidate = record.channelName ?? record['channel_name'];
28840
- if (typeof channelCandidate === 'string' && channelCandidate.trim().length > 0) {
28865
+ if (typeof channelCandidate === 'string' &&
28866
+ channelCandidate.trim().length > 0) {
28841
28867
  config.channelName = channelCandidate.trim();
28842
28868
  }
28843
- const inboxCandidate = record.inboxCapacity ?? record['inbox_capacity'];
28869
+ const inboxCandidate = record.inboxCapacity ??
28870
+ record['inbox_capacity'];
28844
28871
  if (typeof inboxCandidate === 'number' &&
28845
28872
  Number.isFinite(inboxCandidate) &&
28846
28873
  inboxCandidate > 0) {
@@ -28864,9 +28891,11 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28864
28891
  throw new Error('BroadcastChannelConnectorFactory requires a configuration');
28865
28892
  }
28866
28893
  const normalized = this._normalizeConfig(config);
28867
- const options = (factoryArgs[0] ?? {});
28894
+ const options = (factoryArgs[0] ??
28895
+ {});
28868
28896
  const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28869
- const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28897
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ??
28898
+ normalizedLocalNodeFromConfig;
28870
28899
  if (!localNodeId) {
28871
28900
  throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
28872
28901
  }
@@ -28891,6 +28920,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28891
28920
  inboxCapacity,
28892
28921
  localNodeId,
28893
28922
  initialTargetNodeId: resolvedTarget,
28923
+ passive: normalized.passive,
28894
28924
  };
28895
28925
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
28896
28926
  if (options.authorization) {
@@ -28929,6 +28959,9 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28929
28959
  if (normalizedLocalNodeId) {
28930
28960
  normalized.localNodeId = normalizedLocalNodeId;
28931
28961
  }
28962
+ if (typeof candidate.passive === 'boolean') {
28963
+ normalized.passive = candidate.passive;
28964
+ }
28932
28965
  if (typeof candidate.flowControl === 'boolean') {
28933
28966
  normalized.flowControl = candidate.flowControl;
28934
28967
  }
@@ -29009,7 +29042,9 @@ function normalizeConfig$r(config) {
29009
29042
  : DEFAULT_CHANNEL$4;
29010
29043
  const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
29011
29044
  let inboxCapacity = DEFAULT_INBOX_CAPACITY$4;
29012
- if (typeof rawInbox === 'number' && Number.isFinite(rawInbox) && rawInbox > 0) {
29045
+ if (typeof rawInbox === 'number' &&
29046
+ Number.isFinite(rawInbox) &&
29047
+ rawInbox > 0) {
29013
29048
  inboxCapacity = Math.floor(rawInbox);
29014
29049
  }
29015
29050
  else if (typeof rawInbox === 'string') {
@@ -29526,7 +29561,8 @@ class InPageConnectorFactory extends ConnectorFactory {
29526
29561
  const normalized = this._normalizeConfig(config);
29527
29562
  const options = (factoryArgs[0] ?? {});
29528
29563
  const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
29529
- const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
29564
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ??
29565
+ normalizedLocalNodeFromConfig;
29530
29566
  if (!localNodeId) {
29531
29567
  throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
29532
29568
  }
@@ -29676,7 +29712,9 @@ function normalizeConfig$p(config) {
29676
29712
  : DEFAULT_CHANNEL$2;
29677
29713
  const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
29678
29714
  let inboxCapacity = DEFAULT_INBOX_CAPACITY$2;
29679
- if (typeof rawInbox === 'number' && Number.isFinite(rawInbox) && rawInbox > 0) {
29715
+ if (typeof rawInbox === 'number' &&
29716
+ Number.isFinite(rawInbox) &&
29717
+ rawInbox > 0) {
29680
29718
  inboxCapacity = Math.floor(rawInbox);
29681
29719
  }
29682
29720
  else if (typeof rawInbox === 'string') {
@@ -29704,9 +29742,7 @@ class InPageListenerFactory extends TransportListenerFactory {
29704
29742
  }
29705
29743
  async create(config, ...factoryArgs) {
29706
29744
  const normalized = normalizeConfig$p(config);
29707
- const [{ InPageListener }] = await Promise.all([
29708
- getInPageListenerModule(),
29709
- ]);
29745
+ const [{ InPageListener }] = await Promise.all([getInPageListenerModule()]);
29710
29746
  return new InPageListener({
29711
29747
  channelName: normalized.channelName,
29712
29748
  inboxCapacity: normalized.inboxCapacity,
@@ -32757,19 +32793,23 @@ function normalizeConfig$a(config) {
32757
32793
  normalized.clientSecretConfig = normalizeSecretSource(clientSecretSource);
32758
32794
  }
32759
32795
  const audienceCandidate = candidate.audience ?? candidate.aud;
32760
- if (typeof audienceCandidate === 'string' && audienceCandidate.trim().length > 0) {
32796
+ if (typeof audienceCandidate === 'string' &&
32797
+ audienceCandidate.trim().length > 0) {
32761
32798
  normalized.audience = audienceCandidate.trim();
32762
32799
  }
32763
32800
  const codeChallengeMethod = candidate.codeChallengeMethod ?? candidate.code_challenge_method;
32764
- if (typeof codeChallengeMethod === 'string' && codeChallengeMethod.trim().length > 0) {
32801
+ if (typeof codeChallengeMethod === 'string' &&
32802
+ codeChallengeMethod.trim().length > 0) {
32765
32803
  normalized.codeChallengeMethod = codeChallengeMethod.trim();
32766
32804
  }
32767
32805
  const codeVerifierLength = candidate.codeVerifierLength ?? candidate.code_verifier_length;
32768
- if (typeof codeVerifierLength === 'number' && Number.isFinite(codeVerifierLength)) {
32806
+ if (typeof codeVerifierLength === 'number' &&
32807
+ Number.isFinite(codeVerifierLength)) {
32769
32808
  normalized.codeVerifierLength = codeVerifierLength;
32770
32809
  }
32771
32810
  const clockSkewSeconds = candidate.clockSkewSeconds ?? candidate.clock_skew_seconds;
32772
- if (typeof clockSkewSeconds === 'number' && Number.isFinite(clockSkewSeconds)) {
32811
+ if (typeof clockSkewSeconds === 'number' &&
32812
+ Number.isFinite(clockSkewSeconds)) {
32773
32813
  normalized.clockSkewSeconds = clockSkewSeconds;
32774
32814
  }
32775
32815
  const loginHintParam = candidate.loginHintParam ?? candidate.login_hint_param;
@@ -32814,8 +32854,8 @@ class OAuth2PkceTokenProviderFactory extends TokenProviderFactory {
32814
32854
  options.audience = normalized.audience;
32815
32855
  }
32816
32856
  if (normalized.codeChallengeMethod) {
32817
- options.codeChallengeMethod = normalized.codeChallengeMethod
32818
- .toUpperCase();
32857
+ options.codeChallengeMethod =
32858
+ normalized.codeChallengeMethod.toUpperCase();
32819
32859
  }
32820
32860
  if (normalized.codeVerifierLength) {
32821
32861
  options.codeVerifierLength = normalized.codeVerifierLength;
@@ -34572,14 +34612,14 @@ var eddsaEnvelopeVerifierFactory = /*#__PURE__*/Object.freeze({
34572
34612
 
34573
34613
  const FACTORY_META$d = {
34574
34614
  base: TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE,
34575
- key: "NoopTrustStoreProvider",
34615
+ key: 'NoopTrustStoreProvider',
34576
34616
  isDefault: true,
34577
34617
  priority: 10,
34578
34618
  };
34579
34619
  class NoopTrustStoreProviderFactory extends TrustStoreProviderFactory {
34580
34620
  constructor() {
34581
34621
  super(...arguments);
34582
- this.type = "NoopTrustStoreProvider";
34622
+ this.type = 'NoopTrustStoreProvider';
34583
34623
  this.isDefault = true;
34584
34624
  this.priority = 10;
34585
34625
  }
@@ -36282,9 +36322,7 @@ const defaultGrantSelectionPolicy = new GrantSelectionPolicy();
36282
36322
  const logger$a = getLogger('naylence.fame.connector.broadcast_channel_listener');
36283
36323
  const DEFAULT_CHANNEL$1 = 'naylence-fabric';
36284
36324
  const DEFAULT_INBOX_CAPACITY$1 = 2048;
36285
- const RESPONSE_TYPE_MASK = FameResponseType.ACK |
36286
- FameResponseType.REPLY |
36287
- FameResponseType.STREAM;
36325
+ const RESPONSE_TYPE_MASK = FameResponseType.ACK | FameResponseType.REPLY | FameResponseType.STREAM;
36288
36326
  const isBrowserEnvironment$2 = () => typeof window !== 'undefined' &&
36289
36327
  typeof BroadcastChannel !== 'undefined' &&
36290
36328
  typeof MessageEvent !== 'undefined';
@@ -36498,9 +36536,7 @@ class BroadcastChannelListener extends TransportListener {
36498
36536
  return null;
36499
36537
  }
36500
36538
  })();
36501
- if (error instanceof ZodError &&
36502
- decoded &&
36503
- decoded.length > 0) {
36539
+ if (error instanceof ZodError && decoded && decoded.length > 0) {
36504
36540
  try {
36505
36541
  const reparsed = JSON.parse(decoded);
36506
36542
  const candidate = reparsed.rtype;
@@ -36723,11 +36759,19 @@ class BroadcastChannelListener extends TransportListener {
36723
36759
  ? Math.floor(initialWindowCandidate)
36724
36760
  : undefined;
36725
36761
  const initialTargetNodeId = this._normalizeNodeId(targetCandidate) ?? targetSystemId;
36762
+ const passive = typeof passiveCandidate === 'boolean' ? passiveCandidate : true;
36763
+ logger$a.debug('broadcast_channel_listener_building_connector_config', {
36764
+ system_id: systemId,
36765
+ channel_name: channelName,
36766
+ passive,
36767
+ has_base_config: !!baseConfig,
36768
+ passive_candidate: passiveCandidate,
36769
+ });
36726
36770
  return {
36727
36771
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36728
36772
  channelName,
36729
36773
  inboxCapacity,
36730
- passive: typeof passiveCandidate === 'boolean' ? passiveCandidate : true,
36774
+ passive,
36731
36775
  initialWindow,
36732
36776
  localNodeId,
36733
36777
  initialTargetNodeId,
@@ -37478,7 +37522,9 @@ class InPageListener extends TransportListener {
37478
37522
  typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
37479
37523
  ? channelCandidate.trim()
37480
37524
  : DEFAULT_CHANNEL;
37481
- const normalizedCapacity = typeof inboxCandidate === 'number' && Number.isFinite(inboxCandidate) && inboxCandidate > 0
37525
+ const normalizedCapacity = typeof inboxCandidate === 'number' &&
37526
+ Number.isFinite(inboxCandidate) &&
37527
+ inboxCandidate > 0
37482
37528
  ? Math.floor(inboxCandidate)
37483
37529
  : DEFAULT_INBOX_CAPACITY;
37484
37530
  this._inboxCapacity = normalizedCapacity;
@@ -37753,7 +37799,8 @@ class InPageListener extends TransportListener {
37753
37799
  if (grant.type === INPAGE_CONNECTION_GRANT_TYPE) {
37754
37800
  return inPageGrantToConnectorConfig(grant);
37755
37801
  }
37756
- if (typeof grant?.toConnectorConfig === 'function') {
37802
+ if (typeof grant
37803
+ ?.toConnectorConfig === 'function') {
37757
37804
  return grant.toConnectorConfig();
37758
37805
  }
37759
37806
  throw new Error(`Unsupported grant type: ${grant.type}`);
@@ -39291,8 +39338,7 @@ function normalizeOptions$2(raw) {
39291
39338
  const scopes = normalizeScopes(camel.scopes) ??
39292
39339
  normalizeScopes(snake.scopes ?? snake.scope) ??
39293
39340
  DEFAULT_SCOPES.slice();
39294
- const audience = coerceString(camel.audience) ??
39295
- coerceString(snake.audience ?? snake.aud);
39341
+ const audience = coerceString(camel.audience) ?? coerceString(snake.audience ?? snake.aud);
39296
39342
  const fetchImpl = (camel.fetchImpl ?? snake.fetch_impl);
39297
39343
  const clockSkewSeconds = coerceNumber(camel.clockSkewSeconds) ??
39298
39344
  coerceNumber(snake.clock_skew_seconds) ??
@@ -40784,4 +40830,4 @@ var websocketTransportProvisioner = /*#__PURE__*/Object.freeze({
40784
40830
  WebSocketTransportProvisionerFactory: WebSocketTransportProvisionerFactory
40785
40831
  });
40786
40832
 
40787
- export { ADMISSION_CLIENT_FACTORY_BASE_TYPE, ATTACHMENT_KEY_VALIDATOR_FACTORY_BASE_TYPE, AUTHORIZER_FACTORY_BASE_TYPE, AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE, AnsiColor, AsyncLock, AttachmentKeyValidator, AuthInjectionStrategyFactory, AuthorizerFactory, BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE, BackPressureFull, BaseAsyncConnector, BaseNodeEventListener, BindingManager, BindingStoreEntryRecord, BrowserAutoKeyCredentialProvider, BrowserWrappedKeyCredentialProvider, CERTIFICATE_MANAGER_FACTORY_BASE_TYPE, CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE, CRYPTO_LEVEL_SECURITY_ORDER, CertificateManagerFactory, ConnectorConfigDefaults, ConnectorFactory, ConsoleMetricsEmitter, CryptoLevel, FACTORY_META$$ as DEFAULT_WELCOME_FACTORY_META, DefaultCryptoProvider, DefaultKeyManager, DefaultSecurityManager, DefaultSecurityPolicy, DefaultWelcomeService, DefaultWelcomeServiceFactory, DevFixedKeyCredentialProvider, ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, ENVELOPE_SIGNER_FACTORY_BASE_TYPE, ENVELOPE_VERIFIER_FACTORY_BASE_TYPE, ENV_VAR_DEFAULT_ENCRYPTION_LEVEL, ENV_VAR_HMAC_SECRET, ENV_VAR_JWKS_URL, ENV_VAR_JWT_ALGORITHM, ENV_VAR_JWT_AUDIENCE$1 as ENV_VAR_JWT_AUDIENCE, ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE, ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, ENV_VAR_JWT_TRUSTED_ISSUER, ENV_VAR_SHOW_ENVELOPES$1 as ENV_VAR_SHOW_ENVELOPES, EdDSAEnvelopeSigner, EncryptedKeyValueStore, EncryptedStorageProviderBase, EncryptedValue, EncryptionConfiguration, EncryptionManagerFactory, EncryptionResult, EncryptionStatus, EnvCredentialProvider, EnvelopeContext, EnvelopeListenerManager, EnvelopeSecurityHandler, EnvelopeSignerFactory, EnvelopeVerifierFactory, FACTORY_META$10 as FACTORY_META, FIXED_PREFIX_LEN, FameAuthorizedDeliveryContextSchema, FameConnectError, FameEnvironmentContext, FameError, FameMessageTooLarge, FameNode, FameNodeAuthorizationContextSchema, FameProtocolError, FameTransportClose, FlowController, GRANT_PURPOSE_NODE_ATTACH, HTTP_CONNECTION_GRANT_TYPE, HTTP_STATELESS_CONNECTOR_TYPE, INPAGE_CONNECTION_GRANT_TYPE, INPAGE_CONNECTOR_TYPE, InMemoryBinding, InMemoryFanoutBroker, InMemoryKeyValueStore, InMemoryReadWriteChannel, InMemoryStorageProvider, InPageConnector, IndexedDBKeyValueStore, IndexedDBStorageProvider, InvalidPassphraseError, JWKValidationError, KEY_MANAGER_FACTORY_BASE_TYPE, KEY_STORE_FACTORY_BASE_TYPE, KeyInfo, KeyManagementHandler, KeyManagerFactory, KeyStore, KeyStoreFactory, KeyValidationError, LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE, LoadBalancerStickinessManagerFactory, LogLevel, LogLevelNames, MemoryMetricsEmitter, NODE_LIKE_FACTORY_BASE_TYPE, NODE_PLACEMENT_STRATEGY_FACTORY_BASE_TYPE, NoOpMetricsEmitter, NoSecurityPolicy, NodeFactory, NodePlacementStrategyFactory, NoneCredentialProvider, NoopEncryptionManager, NoopKeyValidator, NoopTrustStoreProvider, NotAuthorized, PROFILE_NAME_GATED, PROFILE_NAME_GATED_CALLBACK, PROFILE_NAME_OPEN$1 as PROFILE_NAME_OPEN, PROFILE_NAME_OVERLAY, PROFILE_NAME_OVERLAY_CALLBACK, PROFILE_NAME_STRICT_OVERLAY, PromptCredentialProvider, REPLICA_STICKINESS_MANAGER_FACTORY_BASE_TYPE, REQUIRED_FIELDS_BY_KTY, ReplicaStickinessManagerFactory, RootSessionManager, RouteManager, RpcMixin, RpcProxy, SEALED_ENVELOPE_NONCE_LENGTH, SEALED_ENVELOPE_OVERHEAD, SEALED_ENVELOPE_PRIVATE_KEY_LENGTH, SEALED_ENVELOPE_PUBLIC_KEY_LENGTH, SEALED_ENVELOPE_TAG_LENGTH, SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE, SECURITY_MANAGER_FACTORY_BASE_TYPE, SECURITY_POLICY_FACTORY_BASE_TYPE, STORAGE_PROVIDER_FACTORY_BASE_TYPE, SecretSource, SecretStoreCredentialProvider, SecureChannelFrameHandler, SecureChannelManagerFactory, SecurityAction, SecurityRequirements, Sentinel, SentinelFactory, SessionKeyCredentialProvider, SignaturePolicy, SigningConfig as SigningConfigClass, SigningConfiguration, SimpleLoadBalancerStickinessManager, SimpleLoadBalancerStickinessManagerFactory, StaticCredentialProvider, StorageAESEncryptionManager, TOKEN_ISSUER_FACTORY_BASE_TYPE, TOKEN_PROVIDER_FACTORY_BASE_TYPE, TOKEN_VERIFIER_FACTORY_BASE_TYPE, TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE, TaskSpawner, TokenIssuerFactory, TokenProviderFactory, TokenVerifierFactory, TransportProvisionerFactory, TrustStoreProviderFactory, TtlValidationError, UpstreamSessionManager, VALID_CURVES_BY_KTY, VALID_KEY_USES, VERSION, WEBSOCKET_CONNECTION_GRANT_TYPE, WELCOME_SERVICE_FACTORY_BASE_TYPE, WebSocketCloseCode, WebSocketConnector, WebSocketState, WelcomeServiceFactory, _NoopFlowController, __runtimePluginLoader, addEnvelopeFields, addLogLevel, addTimestamp, assertConnectionGrant, assertGrant, basicConfig, broadcastChannelGrantToConnectorConfig, camelToSnakeCase, canonicalJson, capitalizeFirstLetter, color, compareCryptoLevels, compiledPathPattern, consoleTransport, convertWildcardLogicalToDnsConstraint, createConnectorConfig, createEd25519Keypair, createHostLogicalUri, createLogicalUri, createNodeDeliveryContext, createResource, createRpcProxy, createRsaKeypair, createTransportCloseError, createX25519Keypair, credentialToString, currentTraceId$1 as currentTraceId, debounce, decodeBase64Url, decodeFameDataPayload, deepMerge, defaultJsonEncoder, delay, dropEmpty, enableLogging, encodeUtf8, ensureRuntimeFactoriesRegistered, extractId, extractPoolAddressBase, extractPoolBase, filterKeysByUse, formatTimestamp, formatTimestampForConsole$1 as formatTimestampForConsole, frameDigest, getCurrentEnvelope, getFameRoot, getKeyProvider, getKeyStore, getLogger, hasCryptoSupport, hostnameToLogical, hostnamesToLogicals, httpGrantToConnectorConfig, immutableHeaders, inPageGrantToConnectorConfig, isAuthInjectionStrategy, isBroadcastChannelConnectionGrant, isConnectionGrant, isConnectorConfig, isEnvelopeLoggingEnabled, isFameError, isFameErrorType, isGrant, isHttpConnectionGrant, isInPageConnectionGrant, isNodeLike, isPlainObject$3 as isPlainObject, isPoolAddress, isPoolLogical, isRegisterable, isTokenExpired, isTokenProvider, isTokenValid, isWebSocketConnectionGrant, jsonDumps, logicalPatternsToDnsConstraints, logicalToHostname, logicalsToHostnames, matchesPoolAddress, matchesPoolLogical, maybeAwait, nodeWelcomeRouter, nodeWelcomeRouterPlugin, normalizeBroadcastChannelConnectionGrant, normalizeEncryptionConfig, normalizeEnvelopeSnapshot, normalizeHttpConnectionGrant, normalizeInPageConnectionGrant, normalizeInboundCryptoRules, normalizeInboundSigningRules, normalizeOutboundCryptoRules, normalizeOutboundSigningRules, normalizePath, normalizeResponseCryptoRules, normalizeResponseSigningRules, normalizeSecretSource, normalizeSecurityRequirements, normalizeSigningConfig, normalizeWebSocketConnectionGrant, objectToBytes, operation, parseSealedEnvelope, pinoTransport, prettyModel$1 as prettyModel, registerDefaultFactories, registerDefaultKeyStoreFactory, registerNodePlacementStrategyFactory, registerRuntimeFactories, requireCryptoSupport, retryWithBackoff, safeColor, sealedDecrypt, sealedEncrypt, secureDigest, setKeyStore, showEnvelopes$1 as showEnvelopes, sleep, snakeToCamelCase, stringifyNonPrimitives, supportsColor, throttle, urlsafeBase64Decode, urlsafeBase64Encode, validateCacheTtlSec, validateEncryptionKey, validateHostLogical, validateHostLogicals, validateJwkComplete, validateJwkStructure, validateJwkUseField, validateJwtTokenTtlSec, validateKeyCorrelationTtlSec, validateLogical, validateLogicalSegment, validateOAuth2TtlSec, validateSigningKey, validateTtlSec, waitForAll, waitForAllSettled, waitForAny, websocketGrantToConnectorConfig, withEnvelopeContext, withEnvelopeContextAsync, withLegacySnakeCaseKeys, withLock, withTimeout };
40833
+ export { ADMISSION_CLIENT_FACTORY_BASE_TYPE, ATTACHMENT_KEY_VALIDATOR_FACTORY_BASE_TYPE, AUTHORIZER_FACTORY_BASE_TYPE, AUTH_INJECTION_STRATEGY_FACTORY_BASE_TYPE, AnsiColor, AsyncLock, AttachmentKeyValidator, AuthInjectionStrategyFactory, AuthorizerFactory, BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE, BackPressureFull, BaseAsyncConnector, BaseNodeEventListener, BindingManager, BindingStoreEntryRecord, BrowserAutoKeyCredentialProvider, BrowserWrappedKeyCredentialProvider, CERTIFICATE_MANAGER_FACTORY_BASE_TYPE, CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE, CRYPTO_LEVEL_SECURITY_ORDER, CertificateManagerFactory, ConnectorConfigDefaults, ConnectorFactory, ConsoleMetricsEmitter, CryptoLevel, FACTORY_META$$ as DEFAULT_WELCOME_FACTORY_META, DefaultCryptoProvider, DefaultKeyManager, DefaultSecurityManager, DefaultSecurityPolicy, DefaultWelcomeService, DefaultWelcomeServiceFactory, DevFixedKeyCredentialProvider, ENCRYPTION_MANAGER_FACTORY_BASE_TYPE, ENVELOPE_SIGNER_FACTORY_BASE_TYPE, ENVELOPE_VERIFIER_FACTORY_BASE_TYPE, ENV_VAR_DEFAULT_ENCRYPTION_LEVEL, ENV_VAR_HMAC_SECRET, ENV_VAR_JWKS_URL, ENV_VAR_JWT_ALGORITHM, ENV_VAR_JWT_AUDIENCE$1 as ENV_VAR_JWT_AUDIENCE, ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE, ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER, ENV_VAR_JWT_TRUSTED_ISSUER, ENV_VAR_SHOW_ENVELOPES$1 as ENV_VAR_SHOW_ENVELOPES, EdDSAEnvelopeSigner, EncryptedKeyValueStore, EncryptedStorageProviderBase, EncryptedValue, EncryptionConfiguration, EncryptionManagerFactory, EncryptionResult, EncryptionStatus, EnvCredentialProvider, EnvelopeContext, EnvelopeListenerManager, EnvelopeSecurityHandler, EnvelopeSignerFactory, EnvelopeVerifierFactory, FACTORY_META$10 as FACTORY_META, FIXED_PREFIX_LEN, FameAuthorizedDeliveryContextSchema, FameConnectError, FameEnvironmentContext, FameError, FameMessageTooLarge, FameNode, FameNodeAuthorizationContextSchema, FameProtocolError, FameTransportClose, FlowController, GRANT_PURPOSE_NODE_ATTACH, HTTP_CONNECTION_GRANT_TYPE, HTTP_STATELESS_CONNECTOR_TYPE, INPAGE_CONNECTION_GRANT_TYPE, INPAGE_CONNECTOR_TYPE, InMemoryBinding, InMemoryFanoutBroker, InMemoryKeyValueStore, InMemoryReadWriteChannel, InMemoryStorageProvider, InPageConnector, IndexedDBKeyValueStore, IndexedDBStorageProvider, InvalidPassphraseError, JWKValidationError, KEY_MANAGER_FACTORY_BASE_TYPE, KEY_STORE_FACTORY_BASE_TYPE, KeyInfo, KeyManagementHandler, KeyManagerFactory, KeyStore, KeyStoreFactory, KeyValidationError, LOAD_BALANCER_STICKINESS_MANAGER_FACTORY_BASE_TYPE, LoadBalancerStickinessManagerFactory, LogLevel, LogLevelNames, MemoryMetricsEmitter, NODE_LIKE_FACTORY_BASE_TYPE, NODE_PLACEMENT_STRATEGY_FACTORY_BASE_TYPE, NoOpMetricsEmitter, NoSecurityPolicy, NodeFactory, NodePlacementStrategyFactory, NoneCredentialProvider, NoopEncryptionManager, NoopKeyValidator, NoopTrustStoreProvider, NotAuthorized, PROFILE_NAME_GATED, PROFILE_NAME_GATED_CALLBACK, PROFILE_NAME_OPEN$1 as PROFILE_NAME_OPEN, PROFILE_NAME_OVERLAY, PROFILE_NAME_OVERLAY_CALLBACK, PROFILE_NAME_STRICT_OVERLAY, PromptCredentialProvider, REPLICA_STICKINESS_MANAGER_FACTORY_BASE_TYPE, REQUIRED_FIELDS_BY_KTY, ReplicaStickinessManagerFactory, RootSessionManager, RouteManager, RpcMixin, RpcProxy, SEALED_ENVELOPE_NONCE_LENGTH, SEALED_ENVELOPE_OVERHEAD, SEALED_ENVELOPE_PRIVATE_KEY_LENGTH, SEALED_ENVELOPE_PUBLIC_KEY_LENGTH, SEALED_ENVELOPE_TAG_LENGTH, SECURE_CHANNEL_MANAGER_FACTORY_BASE_TYPE, SECURITY_MANAGER_FACTORY_BASE_TYPE, SECURITY_POLICY_FACTORY_BASE_TYPE, STORAGE_PROVIDER_FACTORY_BASE_TYPE, SecretSource, SecretStoreCredentialProvider, SecureChannelFrameHandler, SecureChannelManagerFactory, SecurityAction, SecurityRequirements, Sentinel, SentinelFactory, SessionKeyCredentialProvider, SignaturePolicy, SigningConfig as SigningConfigClass, SigningConfiguration, SimpleLoadBalancerStickinessManager, SimpleLoadBalancerStickinessManagerFactory, StaticCredentialProvider, StorageAESEncryptionManager, TOKEN_ISSUER_FACTORY_BASE_TYPE, TOKEN_PROVIDER_FACTORY_BASE_TYPE, TOKEN_VERIFIER_FACTORY_BASE_TYPE, TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE, TaskSpawner, TokenIssuerFactory, TokenProviderFactory, TokenVerifierFactory, TransportProvisionerFactory, TrustStoreProviderFactory, TtlValidationError, UpstreamSessionManager, VALID_CURVES_BY_KTY, VALID_KEY_USES, VERSION, WEBSOCKET_CONNECTION_GRANT_TYPE, WELCOME_SERVICE_FACTORY_BASE_TYPE, WebSocketCloseCode, WebSocketConnector, WebSocketState, WelcomeServiceFactory, _NoopFlowController, __runtimePluginLoader, addEnvelopeFields, addLogLevel, addTimestamp, assertConnectionGrant, assertGrant, basicConfig, broadcastChannelGrantToConnectorConfig, camelToSnakeCase, canonicalJson, capitalizeFirstLetter, color, compareCryptoLevels, compiledPathPattern, consoleTransport, convertWildcardLogicalToDnsConstraint, createConnectorConfig, createEd25519Keypair, createHostLogicalUri, createLogicalUri, createNodeDeliveryContext, createResource, createRpcProxy, createRsaKeypair, createTransportCloseError, createX25519Keypair, credentialToString, currentTraceId$1 as currentTraceId, debounce, decodeBase64Url, decodeFameDataPayload, deepMerge, defaultJsonEncoder, delay, dropEmpty, enableLogging, encodeUtf8, ensureRuntimeFactoriesRegistered, extractId, extractPoolAddressBase, extractPoolBase, filterKeysByUse, formatTimestamp, formatTimestampForConsole$1 as formatTimestampForConsole, frameDigest, getCurrentEnvelope, getFameRoot, getKeyProvider, getKeyStore, getLogger, hasCryptoSupport, hostnameToLogical, hostnamesToLogicals, httpGrantToConnectorConfig, immutableHeaders, inPageGrantToConnectorConfig, isAuthInjectionStrategy, isBroadcastChannelConnectionGrant, isConnectionGrant, isConnectorConfig, isEnvelopeLoggingEnabled, isFameError, isFameErrorType, isGrant, isHttpConnectionGrant, isInPageConnectionGrant, isNodeLike, isPlainObject$3 as isPlainObject, isPoolAddress, isPoolLogical, isRegisterable, isTokenExpired, isTokenProvider, isTokenValid, isWebSocketConnectionGrant, jsonDumps, logicalPatternsToDnsConstraints, logicalToHostname, logicalsToHostnames, matchesPoolAddress, matchesPoolLogical, maybeAwait, nodeWelcomeRouter, nodeWelcomeRouterPlugin, normalizeBroadcastChannelConnectionGrant, normalizeEncryptionConfig, normalizeEnvelopeSnapshot, normalizeHttpConnectionGrant, normalizeInPageConnectionGrant, normalizeInboundCryptoRules, normalizeInboundSigningRules, normalizeOutboundCryptoRules, normalizeOutboundSigningRules, normalizePath, normalizeResponseCryptoRules, normalizeResponseSigningRules, normalizeSecretSource, normalizeSecurityRequirements, normalizeSigningConfig, normalizeWebSocketConnectionGrant, objectToBytes, operation, parseSealedEnvelope, pinoTransport, prettyModel$1 as prettyModel, registerDefaultFactories, registerDefaultKeyStoreFactory, registerNodePlacementStrategyFactory, registerRuntimeFactories, requireCryptoSupport, retryWithBackoff, safeColor, safeImport, sealedDecrypt, sealedEncrypt, secureDigest, setKeyStore, showEnvelopes$1 as showEnvelopes, sleep, snakeToCamelCase, stringifyNonPrimitives, supportsColor, throttle, urlsafeBase64Decode, urlsafeBase64Encode, validateCacheTtlSec, validateEncryptionKey, validateHostLogical, validateHostLogicals, validateJwkComplete, validateJwkStructure, validateJwkUseField, validateJwtTokenTtlSec, validateKeyCorrelationTtlSec, validateLogical, validateLogicalSegment, validateOAuth2TtlSec, validateSigningKey, validateTtlSec, waitForAll, waitForAllSettled, waitForAny, websocketGrantToConnectorConfig, withEnvelopeContext, withEnvelopeContextAsync, withLegacySnakeCaseKeys, withLock, withTimeout };