@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
@@ -5562,12 +5562,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5562
5562
  }
5563
5563
 
5564
5564
  // This file is auto-generated during build - do not edit manually
5565
- // Generated from package.json version: 0.3.6
5565
+ // Generated from package.json version: 0.3.7
5566
5566
  /**
5567
5567
  * The package version, injected at build time.
5568
5568
  * @internal
5569
5569
  */
5570
- const VERSION = '0.3.6';
5570
+ const VERSION = '0.3.7';
5571
5571
 
5572
5572
  /**
5573
5573
  * Fame errors module - Fame protocol specific error classes
@@ -9726,9 +9726,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
9726
9726
  this.ackDoneSince = new Map();
9727
9727
  this.replyDoneSince = new Map();
9728
9728
  this.pendingAckDispatches = new Set();
9729
- this.recentlyHandled = new Map();
9730
- this.recentlyHandledOrder = [];
9731
- this.recentlyHandledTtlMs = 60000;
9732
9729
  this.isPreparingToStop = false;
9733
9730
  this.shutdownRequestedAtMs = null;
9734
9731
  this.shutdownRetryGraceMs = 1000;
@@ -9964,22 +9961,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
9964
9961
  }
9965
9962
  }
9966
9963
  else {
9967
- const wasRecentlyHandled = await this.lock.runExclusive(async () => this.wasRecentlyHandled(envelope.id));
9968
- if (wasRecentlyHandled) {
9969
- logger$12.debug('tracker_duplicate_envelope_recently_handled', {
9970
- envp_id: envelope.id,
9971
- });
9972
- return new TrackedEnvelope({
9973
- timeoutAtMs: 0,
9974
- overallTimeoutAtMs: 0,
9975
- expectedResponseType: envelope.rtype ?? FameResponseType.NONE,
9976
- createdAtMs: Date.now(),
9977
- status: EnvelopeStatus.HANDLED,
9978
- mailboxType: MailboxType.INBOX,
9979
- originalEnvelope: envelope,
9980
- serviceName: inboxName,
9981
- });
9982
- }
9983
9964
  tracked = new TrackedEnvelope({
9984
9965
  timeoutAtMs: 0,
9985
9966
  overallTimeoutAtMs: 0,
@@ -10001,12 +9982,8 @@ class DefaultDeliveryTracker extends TaskSpawner {
10001
9982
  async onEnvelopeHandled(envelope) {
10002
9983
  const inbox = this.ensureInbox();
10003
9984
  envelope.status = EnvelopeStatus.HANDLED;
9985
+ // Delete the envelope from inbox to prevent growth
10004
9986
  await inbox.delete(envelope.originalEnvelope.id);
10005
- await this.lock.runExclusive(async () => {
10006
- this.markRecentlyHandled(envelope.originalEnvelope.id);
10007
- });
10008
- // Preserve handled envelope to prevent duplicate redelivery during shutdown drains.
10009
- // await inbox.set(envelope.originalEnvelope.id, envelope);
10010
9987
  }
10011
9988
  async onEnvelopeHandleFailed(inboxName, envelope, context, error, isFinalFailure = false) {
10012
9989
  void context;
@@ -10225,9 +10202,9 @@ class DefaultDeliveryTracker extends TaskSpawner {
10225
10202
  });
10226
10203
  await this.markDoneSince(this.replyFutures, trackedEnvelope.originalEnvelope.id, this.replyDoneSince);
10227
10204
  await this.markDoneSince(this.ackFutures, trackedEnvelope.originalEnvelope.id, this.ackDoneSince);
10228
- if (envelope.rtype && Boolean(envelope.rtype & FameResponseType.ACK)) {
10229
- await this.sendAck(envelope);
10230
- }
10205
+ // Note: ACK is already sent in onCorrelatedMessage (lines 655-657)
10206
+ // when the reply envelope is first delivered. No need to send it again here.
10207
+ // Removing this duplicate sendAck call fixes the duplicate DeliveryAck bug.
10231
10208
  for (const handler of this.eventHandlers) {
10232
10209
  await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
10233
10210
  }
@@ -10377,8 +10354,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
10377
10354
  }
10378
10355
  this.streamDone.clear();
10379
10356
  this.correlationToEnvelope.clear();
10380
- this.recentlyHandled.clear();
10381
- this.recentlyHandledOrder.length = 0;
10382
10357
  return values;
10383
10358
  });
10384
10359
  for (const timer of timers) {
@@ -10960,39 +10935,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
10960
10935
  this.pendingAckDispatches.delete(ackDispatch);
10961
10936
  }
10962
10937
  }
10963
- markRecentlyHandled(envelopeId) {
10964
- const now = Date.now();
10965
- this.recentlyHandled.set(envelopeId, now);
10966
- this.recentlyHandledOrder.push(envelopeId);
10967
- this.trimRecentlyHandled(now);
10968
- }
10969
- wasRecentlyHandled(envelopeId) {
10970
- const now = Date.now();
10971
- const timestamp = this.recentlyHandled.get(envelopeId);
10972
- if (timestamp === undefined) {
10973
- return false;
10974
- }
10975
- if (now - timestamp > this.recentlyHandledTtlMs) {
10976
- this.recentlyHandled.delete(envelopeId);
10977
- return false;
10978
- }
10979
- return true;
10980
- }
10981
- trimRecentlyHandled(now) {
10982
- while (this.recentlyHandledOrder.length > 0) {
10983
- const candidate = this.recentlyHandledOrder[0];
10984
- const timestamp = this.recentlyHandled.get(candidate);
10985
- if (timestamp === undefined) {
10986
- this.recentlyHandledOrder.shift();
10987
- continue;
10988
- }
10989
- if (now - timestamp <= this.recentlyHandledTtlMs) {
10990
- break;
10991
- }
10992
- this.recentlyHandled.delete(candidate);
10993
- this.recentlyHandledOrder.shift();
10994
- }
10995
- }
10996
10938
  getShutdownRetryDeferDelay(nowMs) {
10997
10939
  if (!this.isPreparingToStop || this.shutdownRequestedAtMs === null) {
10998
10940
  return null;
@@ -11569,7 +11511,8 @@ const ensureBroadcastEnvironment = () => {
11569
11511
  };
11570
11512
  let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAsyncConnector {
11571
11513
  static generateConnectorId() {
11572
- const globalCrypto = globalThis.crypto;
11514
+ const globalCrypto = globalThis
11515
+ .crypto;
11573
11516
  if (globalCrypto?.randomUUID) {
11574
11517
  return globalCrypto.randomUUID();
11575
11518
  }
@@ -11624,7 +11567,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11624
11567
  this.listenerRegistered = false;
11625
11568
  this.visibilityChangeListenerRegistered = false;
11626
11569
  this.channelName =
11627
- typeof config.channelName === 'string' && config.channelName.trim().length > 0
11570
+ typeof config.channelName === 'string' &&
11571
+ config.channelName.trim().length > 0
11628
11572
  ? config.channelName.trim()
11629
11573
  : DEFAULT_CHANNEL$7;
11630
11574
  const preferredCapacity = typeof config.inboxCapacity === 'number' &&
@@ -11648,6 +11592,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11648
11592
  local_node_id: this.localNodeId,
11649
11593
  target_node_id: this.targetNodeId ?? null,
11650
11594
  inbox_capacity: preferredCapacity,
11595
+ passive: config.passive ?? false,
11651
11596
  timestamp: new Date().toISOString(),
11652
11597
  });
11653
11598
  this.onMsg = (event) => {
@@ -11665,7 +11610,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11665
11610
  channel: this.channelName,
11666
11611
  connector_id: this.connectorId,
11667
11612
  message_type: message && typeof message === 'object'
11668
- ? message.constructor?.name ?? typeof message
11613
+ ? (message.constructor
11614
+ ?.name ?? typeof message)
11669
11615
  : typeof message,
11670
11616
  has_sender_id: Boolean(message?.senderId),
11671
11617
  has_sender_node_id: Boolean(message?.senderNodeId),
@@ -11895,7 +11841,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11895
11841
  timestamp: new Date().toISOString(),
11896
11842
  });
11897
11843
  }
11898
- if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
11844
+ if (this.visibilityChangeListenerRegistered &&
11845
+ this.visibilityChangeHandler &&
11846
+ typeof document !== 'undefined') {
11899
11847
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
11900
11848
  this.visibilityChangeListenerRegistered = false;
11901
11849
  this.visibilityChangeHandler = undefined;
@@ -11923,7 +11871,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11923
11871
  return rawOrEnvelope;
11924
11872
  }
11925
11873
  _isWildcardTarget() {
11926
- return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
11874
+ return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
11927
11875
  }
11928
11876
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
11929
11877
  if (this._isWildcardTarget()) {
@@ -11943,7 +11891,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11943
11891
  return true;
11944
11892
  }
11945
11893
  const expectedSender = this.targetNodeId;
11946
- if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
11894
+ if (expectedSender &&
11895
+ expectedSender !== '*' &&
11896
+ senderNodeId !== expectedSender) {
11947
11897
  logger$10.debug('broadcast_channel_message_rejected', {
11948
11898
  channel: this.channelName,
11949
11899
  connector_id: this.connectorId,
@@ -12117,14 +12067,16 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
12117
12067
  type,
12118
12068
  purpose,
12119
12069
  };
12120
- const channelValue = candidate.channelName ?? candidate['channel_name'];
12070
+ const channelValue = candidate.channelName ??
12071
+ candidate['channel_name'];
12121
12072
  if (channelValue !== undefined) {
12122
12073
  if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
12123
12074
  throw new TypeError('BroadcastChannelConnectionGrant "channelName" must be a non-empty string when provided');
12124
12075
  }
12125
12076
  result.channelName = channelValue.trim();
12126
12077
  }
12127
- const inboxValue = candidate.inboxCapacity ?? candidate['inbox_capacity'];
12078
+ const inboxValue = candidate.inboxCapacity ??
12079
+ candidate['inbox_capacity'];
12128
12080
  if (inboxValue !== undefined) {
12129
12081
  if (typeof inboxValue !== 'number' ||
12130
12082
  !Number.isFinite(inboxValue) ||
@@ -12133,7 +12085,8 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
12133
12085
  }
12134
12086
  result.inboxCapacity = Math.floor(inboxValue);
12135
12087
  }
12136
- const windowValue = candidate.initialWindow ?? candidate['initial_window'];
12088
+ const windowValue = candidate.initialWindow ??
12089
+ candidate['initial_window'];
12137
12090
  if (windowValue !== undefined) {
12138
12091
  if (typeof windowValue !== 'number' ||
12139
12092
  !Number.isFinite(windowValue) ||
@@ -12470,25 +12423,56 @@ class UpstreamSessionManager extends TaskSpawner {
12470
12423
  await connector.start(this.wrappedHandler);
12471
12424
  this.connector = connector;
12472
12425
  const callbackGrants = this.node.gatherSupportedCallbackGrants();
12426
+ logger$$.debug('callback_grants_before_augmentation', {
12427
+ count: callbackGrants.length,
12428
+ types: callbackGrants.map((g) => g.type),
12429
+ });
12430
+ // Check if we should create a broadcast callback grant before processing connection grants
12431
+ // This prevents adding duplicate broadcast grants
12432
+ const shouldAddBroadcastGrant = this.shouldAdvertiseBroadcastGrant(grant, callbackGrants);
12433
+ const broadcastCallbackGrant = shouldAddBroadcastGrant
12434
+ ? this.createBroadcastCallbackGrant(grant)
12435
+ : null;
12436
+ logger$$.debug('broadcast_callback_grant_check', {
12437
+ should_add: shouldAddBroadcastGrant,
12438
+ grant_created: !!broadcastCallbackGrant,
12439
+ });
12473
12440
  // Include admission client's connection grants as callback grants
12474
12441
  // This ensures DirectAdmissionClient grants are available for grant selection
12475
- if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
12442
+ if (welcome.frame.connectionGrants &&
12443
+ Array.isArray(welcome.frame.connectionGrants)) {
12476
12444
  for (const grant of welcome.frame.connectionGrants) {
12477
12445
  if (grant && typeof grant === 'object') {
12478
12446
  // Avoid duplicates by checking if grant already exists
12479
- const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
12447
+ const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
12480
12448
  if (!isDuplicate) {
12481
12449
  callbackGrants.push(grant);
12450
+ logger$$.debug('added_connection_grant_as_callback', {
12451
+ type: grant.type,
12452
+ });
12453
+ }
12454
+ else {
12455
+ logger$$.debug('skipped_duplicate_connection_grant', {
12456
+ type: grant.type,
12457
+ });
12482
12458
  }
12483
12459
  }
12484
12460
  }
12485
12461
  }
12486
- if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
12487
- const augmented = this.createBroadcastCallbackGrant(grant);
12488
- if (augmented) {
12489
- callbackGrants.push(augmented);
12490
- }
12462
+ // Add broadcast grant after connection grants to ensure we don't duplicate
12463
+ // any broadcast grants that may have been in connectionGrants
12464
+ if (broadcastCallbackGrant &&
12465
+ this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
12466
+ callbackGrants.push(broadcastCallbackGrant);
12467
+ logger$$.debug('added_broadcast_callback_grant');
12491
12468
  }
12469
+ else if (broadcastCallbackGrant) {
12470
+ logger$$.debug('skipped_duplicate_broadcast_callback_grant');
12471
+ }
12472
+ logger$$.debug('callback_grants_after_augmentation', {
12473
+ count: callbackGrants.length,
12474
+ types: callbackGrants.map((g) => g.type),
12475
+ });
12492
12476
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
12493
12477
  this.targetSystemId = attachInfo.targetSystemId ?? null;
12494
12478
  if (this.targetSystemId) {
@@ -12729,7 +12713,8 @@ class UpstreamSessionManager extends TaskSpawner {
12729
12713
  continue;
12730
12714
  }
12731
12715
  // Reset ack time if just resumed from pause (prevents immediate timeout)
12732
- if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
12716
+ if (previousState === ConnectorState.PAUSED &&
12717
+ currentState === ConnectorState.STARTED) {
12733
12718
  logger$$.debug('connector_just_resumed_resetting_ack_time', {
12734
12719
  previous_state: previousState,
12735
12720
  current_state: currentState,
@@ -14286,15 +14271,30 @@ class DefaultNodeAttachClient {
14286
14271
  constructor(options = {}) {
14287
14272
  this.buffer = [];
14288
14273
  this.inHandshake = false;
14274
+ this.expectedSystemId = null;
14289
14275
  this.timeoutMs = options.timeoutMs ?? 10000;
14290
14276
  this.attachmentKeyValidator = options.attachmentKeyValidator;
14291
14277
  this.replicaStickinessManager = options.replicaStickinessManager ?? null;
14292
14278
  }
14293
14279
  async attach(node, originType, connector, welcomeFrame, finalHandler, keys, callbackGrants) {
14294
14280
  this.inHandshake = true;
14281
+ this.expectedSystemId = welcomeFrame.systemId;
14295
14282
  const interimHandler = async (envelope, context) => {
14296
14283
  if (this.inHandshake) {
14297
- this.buffer.push(envelope);
14284
+ // Filter: only buffer frames related to our systemId or frames without systemId info
14285
+ const frameSystemId = envelope.frame
14286
+ ?.systemId;
14287
+ if (!frameSystemId || frameSystemId === this.expectedSystemId) {
14288
+ this.buffer.push(envelope);
14289
+ }
14290
+ else {
14291
+ // Silently ignore frames from other agents during concurrent handshakes
14292
+ logger$Y.debug('handshake_ignoring_frame_from_different_system', {
14293
+ frame_type: envelope.frame.type,
14294
+ frame_system_id: frameSystemId,
14295
+ expected_system_id: this.expectedSystemId,
14296
+ });
14297
+ }
14298
14298
  return null;
14299
14299
  }
14300
14300
  return finalHandler(envelope, context);
@@ -14421,6 +14421,7 @@ class DefaultNodeAttachClient {
14421
14421
  parent_id: ackFrame.targetSystemId,
14422
14422
  });
14423
14423
  this.inHandshake = false;
14424
+ this.expectedSystemId = null;
14424
14425
  await connector.replaceHandler(finalHandler);
14425
14426
  while (this.buffer.length > 0) {
14426
14427
  const bufferedEnvelope = this.buffer.shift();
@@ -14478,7 +14479,8 @@ class DefaultNodeAttachClient {
14478
14479
  const deadline = Date.now() + this.timeoutMs;
14479
14480
  while (Date.now() < deadline) {
14480
14481
  // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
14481
- if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
14482
+ if (connector.state !== ConnectorState.STARTED &&
14483
+ connector.state !== ConnectorState.PAUSED) {
14482
14484
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
14483
14485
  if (connector.closeCode !== undefined) {
14484
14486
  errorMessage += ` (code=${connector.closeCode}`;
@@ -14497,9 +14499,21 @@ class DefaultNodeAttachClient {
14497
14499
  if (envelope.frame.type === 'NodeAttachAck') {
14498
14500
  return envelope;
14499
14501
  }
14500
- logger$Y.error('unexpected_frame_during_handshake', {
14501
- frame_type: envelope.frame.type,
14502
- });
14502
+ // NodeAttach frames during handshake are expected in multi-agent scenarios
14503
+ // where multiple agents attach concurrently to the same channel
14504
+ if (envelope.frame.type === 'NodeAttach') {
14505
+ logger$Y.debug('handshake_ignoring_concurrent_attach', {
14506
+ frame_type: envelope.frame.type,
14507
+ frame_system_id: envelope.frame?.systemId ??
14508
+ 'unknown',
14509
+ });
14510
+ }
14511
+ else {
14512
+ // Other unexpected frames are still logged as errors
14513
+ logger$Y.error('unexpected_frame_during_handshake', {
14514
+ frame_type: envelope.frame.type,
14515
+ });
14516
+ }
14503
14517
  }
14504
14518
  await delay(HANDSHAKE_POLL_INTERVAL_MS);
14505
14519
  }
@@ -15218,7 +15232,8 @@ function createFsShim() {
15218
15232
  else if (options &&
15219
15233
  typeof options === 'object' &&
15220
15234
  'encoding' in options &&
15221
- typeof options.encoding === 'string') {
15235
+ typeof options.encoding ===
15236
+ 'string') {
15222
15237
  encoding = options.encoding;
15223
15238
  }
15224
15239
  const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
@@ -21637,7 +21652,8 @@ class InPageConnector extends BaseAsyncConnector {
21637
21652
  this.listenerRegistered = false;
21638
21653
  this.visibilityChangeListenerRegistered = false;
21639
21654
  this.channelName =
21640
- typeof config.channelName === 'string' && config.channelName.trim().length > 0
21655
+ typeof config.channelName === 'string' &&
21656
+ config.channelName.trim().length > 0
21641
21657
  ? config.channelName.trim()
21642
21658
  : DEFAULT_CHANNEL$6;
21643
21659
  const preferredCapacity = typeof config.inboxCapacity === 'number' &&
@@ -21676,7 +21692,8 @@ class InPageConnector extends BaseAsyncConnector {
21676
21692
  channel: this.channelName,
21677
21693
  connector_id: this.connectorId,
21678
21694
  message_type: message && typeof message === 'object'
21679
- ? message.constructor?.name ?? typeof message
21695
+ ? (message.constructor
21696
+ ?.name ?? typeof message)
21680
21697
  : typeof message,
21681
21698
  has_sender_id: Boolean(message?.senderId),
21682
21699
  has_sender_node_id: Boolean(message?.senderNodeId),
@@ -21685,7 +21702,8 @@ class InPageConnector extends BaseAsyncConnector {
21685
21702
  return;
21686
21703
  }
21687
21704
  const busMessage = message;
21688
- const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
21705
+ const senderId = typeof busMessage.senderId === 'string' &&
21706
+ busMessage.senderId.length > 0
21689
21707
  ? busMessage.senderId
21690
21708
  : null;
21691
21709
  const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
@@ -21936,7 +21954,9 @@ class InPageConnector extends BaseAsyncConnector {
21936
21954
  timestamp: new Date().toISOString(),
21937
21955
  });
21938
21956
  }
21939
- if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
21957
+ if (this.visibilityChangeListenerRegistered &&
21958
+ this.visibilityChangeHandler &&
21959
+ typeof document !== 'undefined') {
21940
21960
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
21941
21961
  this.visibilityChangeListenerRegistered = false;
21942
21962
  this.visibilityChangeHandler = undefined;
@@ -21953,7 +21973,7 @@ class InPageConnector extends BaseAsyncConnector {
21953
21973
  return rawOrEnvelope;
21954
21974
  }
21955
21975
  _isWildcardTarget() {
21956
- return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
21976
+ return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
21957
21977
  }
21958
21978
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
21959
21979
  if (this._isWildcardTarget()) {
@@ -21973,7 +21993,9 @@ class InPageConnector extends BaseAsyncConnector {
21973
21993
  return true;
21974
21994
  }
21975
21995
  const expectedSender = this.targetNodeId;
21976
- if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
21996
+ if (expectedSender &&
21997
+ expectedSender !== '*' &&
21998
+ senderNodeId !== expectedSender) {
21977
21999
  logger$J.debug('inpage_message_rejected', {
21978
22000
  channel: this.channelName,
21979
22001
  connector_id: this.connectorId,
@@ -22375,8 +22397,8 @@ class CertificateManagerFactory extends AbstractResourceFactory {
22375
22397
  }
22376
22398
  }
22377
22399
 
22378
- 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.";
22379
- const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = "TrustStoreProviderFactory";
22400
+ 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.';
22401
+ const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = 'TrustStoreProviderFactory';
22380
22402
  class TrustStoreProviderFactory extends AbstractResourceFactory {
22381
22403
  createUnconfiguredProvider(reason) {
22382
22404
  return new NoopTrustStoreProvider(reason ?? DEFAULT_UNCONFIGURED_MESSAGE);
@@ -26105,7 +26127,8 @@ class DefaultSecurityManager {
26105
26127
  const hasSignature = Boolean(envelope.sec?.sig);
26106
26128
  if (!hasSignature) {
26107
26129
  const nodeSid = node.sid;
26108
- const envelopeSid = envelope.sid;
26130
+ const envelopeSid = envelope
26131
+ .sid;
26109
26132
  const isLocalUnsignedSelfEnvelope = localContext.originType === DeliveryOriginType.LOCAL &&
26110
26133
  typeof nodeSid === 'string' &&
26111
26134
  nodeSid.length > 0 &&
@@ -29349,14 +29372,16 @@ function normalizeInPageConnectionGrant(candidate) {
29349
29372
  type,
29350
29373
  purpose,
29351
29374
  };
29352
- const channelValue = candidate.channelName ?? candidate['channel_name'];
29375
+ const channelValue = candidate.channelName ??
29376
+ candidate['channel_name'];
29353
29377
  if (channelValue !== undefined) {
29354
29378
  if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
29355
29379
  throw new TypeError('InPageConnectionGrant "channelName" must be a non-empty string when provided');
29356
29380
  }
29357
29381
  result.channelName = channelValue.trim();
29358
29382
  }
29359
- const inboxValue = candidate.inboxCapacity ?? candidate['inbox_capacity'];
29383
+ const inboxValue = candidate.inboxCapacity ??
29384
+ candidate['inbox_capacity'];
29360
29385
  if (inboxValue !== undefined) {
29361
29386
  if (typeof inboxValue !== 'number' ||
29362
29387
  !Number.isFinite(inboxValue) ||
@@ -30162,7 +30187,9 @@ function normalizeConfig$p(config) {
30162
30187
  : DEFAULT_CHANNEL$5;
30163
30188
  const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
30164
30189
  let inboxCapacity = DEFAULT_INBOX_CAPACITY$5;
30165
- if (typeof rawInbox === 'number' && Number.isFinite(rawInbox) && rawInbox > 0) {
30190
+ if (typeof rawInbox === 'number' &&
30191
+ Number.isFinite(rawInbox) &&
30192
+ rawInbox > 0) {
30166
30193
  inboxCapacity = Math.floor(rawInbox);
30167
30194
  }
30168
30195
  else if (typeof rawInbox === 'string') {
@@ -30190,9 +30217,7 @@ class InPageListenerFactory extends TransportListenerFactory {
30190
30217
  }
30191
30218
  async create(config, ...factoryArgs) {
30192
30219
  const normalized = normalizeConfig$p(config);
30193
- const [{ InPageListener }] = await Promise.all([
30194
- getInPageListenerModule(),
30195
- ]);
30220
+ const [{ InPageListener }] = await Promise.all([getInPageListenerModule()]);
30196
30221
  void factoryArgs;
30197
30222
  return new InPageListener({
30198
30223
  channelName: normalized.channelName,
@@ -30225,7 +30250,9 @@ function normalizeConfig$o(config) {
30225
30250
  : DEFAULT_CHANNEL$4;
30226
30251
  const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
30227
30252
  let inboxCapacity = DEFAULT_INBOX_CAPACITY$4;
30228
- if (typeof rawInbox === 'number' && Number.isFinite(rawInbox) && rawInbox > 0) {
30253
+ if (typeof rawInbox === 'number' &&
30254
+ Number.isFinite(rawInbox) &&
30255
+ rawInbox > 0) {
30229
30256
  inboxCapacity = Math.floor(rawInbox);
30230
30257
  }
30231
30258
  else if (typeof rawInbox === 'string') {
@@ -30630,7 +30657,8 @@ class InPageConnectorFactory extends ConnectorFactory {
30630
30657
  const normalized = this._normalizeConfig(config);
30631
30658
  const options = (factoryArgs[0] ?? {});
30632
30659
  const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
30633
- const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
30660
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ??
30661
+ normalizedLocalNodeFromConfig;
30634
30662
  if (!localNodeId) {
30635
30663
  throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
30636
30664
  }
@@ -30806,10 +30834,12 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30806
30834
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
30807
30835
  };
30808
30836
  const channelCandidate = record.channelName ?? record['channel_name'];
30809
- if (typeof channelCandidate === 'string' && channelCandidate.trim().length > 0) {
30837
+ if (typeof channelCandidate === 'string' &&
30838
+ channelCandidate.trim().length > 0) {
30810
30839
  config.channelName = channelCandidate.trim();
30811
30840
  }
30812
- const inboxCandidate = record.inboxCapacity ?? record['inbox_capacity'];
30841
+ const inboxCandidate = record.inboxCapacity ??
30842
+ record['inbox_capacity'];
30813
30843
  if (typeof inboxCandidate === 'number' &&
30814
30844
  Number.isFinite(inboxCandidate) &&
30815
30845
  inboxCandidate > 0) {
@@ -30833,9 +30863,11 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30833
30863
  throw new Error('BroadcastChannelConnectorFactory requires a configuration');
30834
30864
  }
30835
30865
  const normalized = this._normalizeConfig(config);
30836
- const options = (factoryArgs[0] ?? {});
30866
+ const options = (factoryArgs[0] ??
30867
+ {});
30837
30868
  const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
30838
- const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
30869
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ??
30870
+ normalizedLocalNodeFromConfig;
30839
30871
  if (!localNodeId) {
30840
30872
  throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
30841
30873
  }
@@ -30860,6 +30892,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30860
30892
  inboxCapacity,
30861
30893
  localNodeId,
30862
30894
  initialTargetNodeId: resolvedTarget,
30895
+ passive: normalized.passive,
30863
30896
  };
30864
30897
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
30865
30898
  if (options.authorization) {
@@ -30898,6 +30931,9 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30898
30931
  if (normalizedLocalNodeId) {
30899
30932
  normalized.localNodeId = normalizedLocalNodeId;
30900
30933
  }
30934
+ if (typeof candidate.passive === 'boolean') {
30935
+ normalized.passive = candidate.passive;
30936
+ }
30901
30937
  if (typeof candidate.flowControl === 'boolean') {
30902
30938
  normalized.flowControl = candidate.flowControl;
30903
30939
  }
@@ -32439,7 +32475,9 @@ class InPageListener extends TransportListener {
32439
32475
  typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
32440
32476
  ? channelCandidate.trim()
32441
32477
  : DEFAULT_CHANNEL$1;
32442
- const normalizedCapacity = typeof inboxCandidate === 'number' && Number.isFinite(inboxCandidate) && inboxCandidate > 0
32478
+ const normalizedCapacity = typeof inboxCandidate === 'number' &&
32479
+ Number.isFinite(inboxCandidate) &&
32480
+ inboxCandidate > 0
32443
32481
  ? Math.floor(inboxCandidate)
32444
32482
  : DEFAULT_INBOX_CAPACITY$1;
32445
32483
  this._inboxCapacity = normalizedCapacity;
@@ -32714,7 +32752,8 @@ class InPageListener extends TransportListener {
32714
32752
  if (grant.type === INPAGE_CONNECTION_GRANT_TYPE) {
32715
32753
  return inPageGrantToConnectorConfig(grant);
32716
32754
  }
32717
- if (typeof grant?.toConnectorConfig === 'function') {
32755
+ if (typeof grant
32756
+ ?.toConnectorConfig === 'function') {
32718
32757
  return grant.toConnectorConfig();
32719
32758
  }
32720
32759
  throw new Error(`Unsupported grant type: ${grant.type}`);
@@ -32854,9 +32893,7 @@ var inpageListener = /*#__PURE__*/Object.freeze({
32854
32893
  const logger$n = getLogger('naylence.fame.connector.broadcast_channel_listener');
32855
32894
  const DEFAULT_CHANNEL = 'naylence-fabric';
32856
32895
  const DEFAULT_INBOX_CAPACITY = 2048;
32857
- const RESPONSE_TYPE_MASK = FameResponseType.ACK |
32858
- FameResponseType.REPLY |
32859
- FameResponseType.STREAM;
32896
+ const RESPONSE_TYPE_MASK = FameResponseType.ACK | FameResponseType.REPLY | FameResponseType.STREAM;
32860
32897
  const isBrowserEnvironment$1 = () => typeof window !== 'undefined' &&
32861
32898
  typeof BroadcastChannel !== 'undefined' &&
32862
32899
  typeof MessageEvent !== 'undefined';
@@ -33070,9 +33107,7 @@ class BroadcastChannelListener extends TransportListener {
33070
33107
  return null;
33071
33108
  }
33072
33109
  })();
33073
- if (error instanceof ZodError &&
33074
- decoded &&
33075
- decoded.length > 0) {
33110
+ if (error instanceof ZodError && decoded && decoded.length > 0) {
33076
33111
  try {
33077
33112
  const reparsed = JSON.parse(decoded);
33078
33113
  const candidate = reparsed.rtype;
@@ -33295,11 +33330,19 @@ class BroadcastChannelListener extends TransportListener {
33295
33330
  ? Math.floor(initialWindowCandidate)
33296
33331
  : undefined;
33297
33332
  const initialTargetNodeId = this._normalizeNodeId(targetCandidate) ?? targetSystemId;
33333
+ const passive = typeof passiveCandidate === 'boolean' ? passiveCandidate : true;
33334
+ logger$n.debug('broadcast_channel_listener_building_connector_config', {
33335
+ system_id: systemId,
33336
+ channel_name: channelName,
33337
+ passive,
33338
+ has_base_config: !!baseConfig,
33339
+ passive_candidate: passiveCandidate,
33340
+ });
33298
33341
  return {
33299
33342
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
33300
33343
  channelName,
33301
33344
  inboxCapacity,
33302
- passive: typeof passiveCandidate === 'boolean' ? passiveCandidate : true,
33345
+ passive,
33303
33346
  initialWindow,
33304
33347
  localNodeId,
33305
33348
  initialTargetNodeId,
@@ -34169,7 +34212,9 @@ function parseCookies(cookieHeader) {
34169
34212
  if (!cookieHeader) {
34170
34213
  return {};
34171
34214
  }
34172
- return cookieHeader.split(';').reduce((acc, entry) => {
34215
+ return cookieHeader
34216
+ .split(';')
34217
+ .reduce((acc, entry) => {
34173
34218
  const [rawName, ...rawValueParts] = entry.split('=');
34174
34219
  const name = rawName?.trim();
34175
34220
  if (!name) {
@@ -34317,10 +34362,7 @@ function setNoCacheHeaders(res) {
34317
34362
  res.set('Pragma', 'no-cache');
34318
34363
  }
34319
34364
  function respondInvalidClient(res) {
34320
- res
34321
- .status(401)
34322
- .set('WWW-Authenticate', 'Basic')
34323
- .json({
34365
+ res.status(401).set('WWW-Authenticate', 'Basic').json({
34324
34366
  error: 'invalid_client',
34325
34367
  error_description: 'Invalid client credentials',
34326
34368
  });
@@ -34357,10 +34399,10 @@ function createOAuth2TokenRouter(options) {
34357
34399
  DEFAULT_JWT_ALGORITHM$1;
34358
34400
  const allowedScopes = getAllowedScopes$1(configAllowedScopes);
34359
34401
  const resolvedTokenTtlSec = tokenTtlSec ?? 3600;
34360
- const enablePkce = coerceBoolean(process.env[ENV_VAR_ENABLE_PKCE]) ??
34361
- (configEnablePkce ?? true);
34402
+ const enablePkce = coerceBoolean(process.env[ENV_VAR_ENABLE_PKCE]) ?? configEnablePkce ?? true;
34362
34403
  const allowPublicClients = coerceBoolean(process.env[ENV_VAR_ALLOW_PUBLIC_CLIENTS]) ??
34363
- (configAllowPublicClients ?? true);
34404
+ configAllowPublicClients ??
34405
+ true;
34364
34406
  const authorizationCodeTtlSec = ensurePositiveInteger(coerceNumber$1(process.env[ENV_VAR_AUTHORIZATION_CODE_TTL]) ??
34365
34407
  configAuthorizationCodeTtlSec) ?? DEFAULT_AUTHORIZATION_CODE_TTL_SEC;
34366
34408
  const devLoginExplicitlyEnabled = coerceBoolean(process.env[ENV_VAR_ENABLE_DEV_LOGIN]) ??
@@ -34375,7 +34417,8 @@ function createOAuth2TokenRouter(options) {
34375
34417
  configDevLoginCookieName ??
34376
34418
  DEFAULT_SESSION_COOKIE_NAME;
34377
34419
  const devLoginSecureCookie = coerceBoolean(process.env[ENV_VAR_SESSION_SECURE_COOKIE]) ??
34378
- (configDevLoginSecureCookie ?? false);
34420
+ configDevLoginSecureCookie ??
34421
+ false;
34379
34422
  const devLoginTitle = coerceString$2(process.env[ENV_VAR_LOGIN_TITLE]) ??
34380
34423
  configDevLoginTitle ??
34381
34424
  DEFAULT_LOGIN_TITLE;
@@ -37442,19 +37485,23 @@ function normalizeConfig$a(config) {
37442
37485
  normalized.clientSecretConfig = normalizeSecretSource(clientSecretSource);
37443
37486
  }
37444
37487
  const audienceCandidate = candidate.audience ?? candidate.aud;
37445
- if (typeof audienceCandidate === 'string' && audienceCandidate.trim().length > 0) {
37488
+ if (typeof audienceCandidate === 'string' &&
37489
+ audienceCandidate.trim().length > 0) {
37446
37490
  normalized.audience = audienceCandidate.trim();
37447
37491
  }
37448
37492
  const codeChallengeMethod = candidate.codeChallengeMethod ?? candidate.code_challenge_method;
37449
- if (typeof codeChallengeMethod === 'string' && codeChallengeMethod.trim().length > 0) {
37493
+ if (typeof codeChallengeMethod === 'string' &&
37494
+ codeChallengeMethod.trim().length > 0) {
37450
37495
  normalized.codeChallengeMethod = codeChallengeMethod.trim();
37451
37496
  }
37452
37497
  const codeVerifierLength = candidate.codeVerifierLength ?? candidate.code_verifier_length;
37453
- if (typeof codeVerifierLength === 'number' && Number.isFinite(codeVerifierLength)) {
37498
+ if (typeof codeVerifierLength === 'number' &&
37499
+ Number.isFinite(codeVerifierLength)) {
37454
37500
  normalized.codeVerifierLength = codeVerifierLength;
37455
37501
  }
37456
37502
  const clockSkewSeconds = candidate.clockSkewSeconds ?? candidate.clock_skew_seconds;
37457
- if (typeof clockSkewSeconds === 'number' && Number.isFinite(clockSkewSeconds)) {
37503
+ if (typeof clockSkewSeconds === 'number' &&
37504
+ Number.isFinite(clockSkewSeconds)) {
37458
37505
  normalized.clockSkewSeconds = clockSkewSeconds;
37459
37506
  }
37460
37507
  const loginHintParam = candidate.loginHintParam ?? candidate.login_hint_param;
@@ -37499,8 +37546,8 @@ class OAuth2PkceTokenProviderFactory extends TokenProviderFactory {
37499
37546
  options.audience = normalized.audience;
37500
37547
  }
37501
37548
  if (normalized.codeChallengeMethod) {
37502
- options.codeChallengeMethod = normalized.codeChallengeMethod
37503
- .toUpperCase();
37549
+ options.codeChallengeMethod =
37550
+ normalized.codeChallengeMethod.toUpperCase();
37504
37551
  }
37505
37552
  if (normalized.codeVerifierLength) {
37506
37553
  options.codeVerifierLength = normalized.codeVerifierLength;
@@ -39258,14 +39305,14 @@ var eddsaEnvelopeVerifierFactory = /*#__PURE__*/Object.freeze({
39258
39305
 
39259
39306
  const FACTORY_META$d = {
39260
39307
  base: TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE,
39261
- key: "NoopTrustStoreProvider",
39308
+ key: 'NoopTrustStoreProvider',
39262
39309
  isDefault: true,
39263
39310
  priority: 10,
39264
39311
  };
39265
39312
  class NoopTrustStoreProviderFactory extends TrustStoreProviderFactory {
39266
39313
  constructor() {
39267
39314
  super(...arguments);
39268
- this.type = "NoopTrustStoreProvider";
39315
+ this.type = 'NoopTrustStoreProvider';
39269
39316
  this.isDefault = true;
39270
39317
  this.priority = 10;
39271
39318
  }
@@ -41503,8 +41550,7 @@ function normalizeOptions$2(raw) {
41503
41550
  const scopes = normalizeScopes(camel.scopes) ??
41504
41551
  normalizeScopes(snake.scopes ?? snake.scope) ??
41505
41552
  DEFAULT_SCOPES.slice();
41506
- const audience = coerceString(camel.audience) ??
41507
- coerceString(snake.audience ?? snake.aud);
41553
+ const audience = coerceString(camel.audience) ?? coerceString(snake.audience ?? snake.aud);
41508
41554
  const fetchImpl = (camel.fetchImpl ?? snake.fetch_impl);
41509
41555
  const clockSkewSeconds = coerceNumber(camel.clockSkewSeconds) ??
41510
41556
  coerceNumber(snake.clock_skew_seconds) ??
@@ -43002,4 +43048,4 @@ var websocketTransportProvisioner = /*#__PURE__*/Object.freeze({
43002
43048
  WebSocketTransportProvisionerFactory: WebSocketTransportProvisionerFactory
43003
43049
  });
43004
43050
 
43005
- 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, DefaultHttpServer, 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$2 as ENV_VAR_JWT_ALGORITHM, ENV_VAR_JWT_AUDIENCE$2 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$$ as FACTORY_META, FAME_FABRIC_FACTORY_BASE_TYPE, 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, HttpListener, HttpStatelessConnector, INPAGE_CONNECTION_GRANT_TYPE, INPAGE_CONNECTOR_TYPE, InMemoryBinding, InMemoryFanoutBroker, InMemoryKeyValueStore, InMemoryReadWriteChannel, InMemoryStorageProvider, InPageConnector, InPageListener, InProcessFameFabric, InProcessFameFabricFactory, 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, QueueFullError, 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, SQLiteKeyValueStore, SQLiteStorageProvider, 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_LISTENER_FACTORY_BASE_TYPE, TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE, TaskSpawner, TokenIssuerFactory, TokenProviderFactory, TokenVerifierFactory, TransportListener, TransportProvisionerFactory, TrustStoreProviderFactory, TtlValidationError, UpstreamSessionManager, VALID_CURVES_BY_KTY, VALID_KEY_USES, VERSION, WEBSOCKET_CONNECTION_GRANT_TYPE, WELCOME_SERVICE_FACTORY_BASE_TYPE, WebSocketCloseCode, WebSocketConnector, WebSocketListener, WebSocketState, WelcomeServiceFactory, _NoopFlowController, __runtimePluginLoader, addEnvelopeFields, addLogLevel, addTimestamp, assertConnectionGrant, assertGrant, basicConfig, broadcastChannelGrantToConnectorConfig, camelToSnakeCase, canonicalJson, capitalizeFirstLetter, color, compareCryptoLevels, compiledPathPattern, consoleTransport, convertWildcardLogicalToDnsConstraint, createConnectorConfig, createEd25519Keypair, createHostLogicalUri, createJwksRouter, createLogicalUri, createNodeDeliveryContext, createApp as createOAuth2ServerApp, createOAuth2TokenRouter, createOpenIDConfigurationRouter, 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, getHttpListenerInstance, getInPageListenerInstance, getKeyProvider, getKeyStore, getLogger, getWebsocketListenerInstance, 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, normalizeExtendedFameConfig, 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, main as runOAuth2Server, 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 };
43051
+ 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, DefaultHttpServer, 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$2 as ENV_VAR_JWT_ALGORITHM, ENV_VAR_JWT_AUDIENCE$2 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$$ as FACTORY_META, FAME_FABRIC_FACTORY_BASE_TYPE, 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, HttpListener, HttpStatelessConnector, INPAGE_CONNECTION_GRANT_TYPE, INPAGE_CONNECTOR_TYPE, InMemoryBinding, InMemoryFanoutBroker, InMemoryKeyValueStore, InMemoryReadWriteChannel, InMemoryStorageProvider, InPageConnector, InPageListener, InProcessFameFabric, InProcessFameFabricFactory, 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, QueueFullError, 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, SQLiteKeyValueStore, SQLiteStorageProvider, 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_LISTENER_FACTORY_BASE_TYPE, TRANSPORT_PROVISIONER_FACTORY_BASE_TYPE, TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE, TaskSpawner, TokenIssuerFactory, TokenProviderFactory, TokenVerifierFactory, TransportListener, TransportListenerFactory, TransportProvisionerFactory, TrustStoreProviderFactory, TtlValidationError, UpstreamSessionManager, VALID_CURVES_BY_KTY, VALID_KEY_USES, VERSION, WEBSOCKET_CONNECTION_GRANT_TYPE, WELCOME_SERVICE_FACTORY_BASE_TYPE, WebSocketCloseCode, WebSocketConnector, WebSocketListener, WebSocketState, WelcomeServiceFactory, _NoopFlowController, __runtimePluginLoader, addEnvelopeFields, addLogLevel, addTimestamp, assertConnectionGrant, assertGrant, basicConfig, broadcastChannelGrantToConnectorConfig, camelToSnakeCase, canonicalJson, capitalizeFirstLetter, color, compareCryptoLevels, compiledPathPattern, consoleTransport, convertWildcardLogicalToDnsConstraint, createConnectorConfig, createEd25519Keypair, createHostLogicalUri, createJwksRouter, createLogicalUri, createNodeDeliveryContext, createApp as createOAuth2ServerApp, createOAuth2TokenRouter, createOpenIDConfigurationRouter, 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, getHttpListenerInstance, getInPageListenerInstance, getKeyProvider, getKeyStore, getLogger, getWebsocketListenerInstance, 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, normalizeExtendedFameConfig, 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, main as runOAuth2Server, 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 };