@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
@@ -28,7 +28,8 @@ function installProcessEnvShim() {
28
28
  if (g.__ENV__ && typeof g.__ENV__ === 'object')
29
29
  Object.assign(out, g.__ENV__);
30
30
  try {
31
- // @ts-ignore -- import.meta is only available in ESM builds
31
+ // import.meta is only available in ESM builds
32
+ // @ts-ignore
32
33
  const ie = (typeof import.meta !== 'undefined' && import.meta.env) || undefined;
33
34
  if (ie && typeof ie === 'object')
34
35
  Object.assign(out, ie);
@@ -96,12 +97,12 @@ installProcessEnvShim();
96
97
  // --- END ENV SHIM ---
97
98
 
98
99
  // This file is auto-generated during build - do not edit manually
99
- // Generated from package.json version: 0.3.6
100
+ // Generated from package.json version: 0.3.7
100
101
  /**
101
102
  * The package version, injected at build time.
102
103
  * @internal
103
104
  */
104
- const VERSION = '0.3.6';
105
+ const VERSION = '0.3.7';
105
106
 
106
107
  /**
107
108
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -2330,6 +2331,50 @@ function validateKeyCorrelationTtlSec(ttlSec) {
2330
2331
  });
2331
2332
  }
2332
2333
 
2334
+ function isModuleNotFoundError(error) {
2335
+ if (!(error instanceof Error)) {
2336
+ return false;
2337
+ }
2338
+ const message = error.message || '';
2339
+ if (message.includes('Cannot find module') ||
2340
+ message.includes('ERR_MODULE_NOT_FOUND') ||
2341
+ message.includes('MODULE_NOT_FOUND')) {
2342
+ return true;
2343
+ }
2344
+ const code = error.code;
2345
+ if (typeof code === 'string') {
2346
+ return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
2347
+ }
2348
+ return false;
2349
+ }
2350
+ /**
2351
+ * Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
2352
+ */
2353
+ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
2354
+ const options = typeof dependencyNameOrOptions === 'string'
2355
+ ? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
2356
+ : dependencyNameOrOptions;
2357
+ const dependencyName = options.dependencyName;
2358
+ try {
2359
+ return await loader();
2360
+ }
2361
+ catch (error) {
2362
+ if (isModuleNotFoundError(error)) {
2363
+ const message = options.helpMessage ??
2364
+ `Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
2365
+ const enrichedError = new Error(message);
2366
+ try {
2367
+ enrichedError.cause = error;
2368
+ }
2369
+ catch {
2370
+ // Ignore environments that do not support attaching a cause.
2371
+ }
2372
+ throw enrichedError;
2373
+ }
2374
+ throw error;
2375
+ }
2376
+ }
2377
+
2333
2378
  /**
2334
2379
  * flow_controller.ts - credit window management with cooperative back-pressure.
2335
2380
  *
@@ -3534,50 +3579,6 @@ function normalizeSecretSource(value) {
3534
3579
  return SecretSource.normalize(value);
3535
3580
  }
3536
3581
 
3537
- function isModuleNotFoundError(error) {
3538
- if (!(error instanceof Error)) {
3539
- return false;
3540
- }
3541
- const message = error.message || '';
3542
- if (message.includes('Cannot find module') ||
3543
- message.includes('ERR_MODULE_NOT_FOUND') ||
3544
- message.includes('MODULE_NOT_FOUND')) {
3545
- return true;
3546
- }
3547
- const code = error.code;
3548
- if (typeof code === 'string') {
3549
- return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
3550
- }
3551
- return false;
3552
- }
3553
- /**
3554
- * Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
3555
- */
3556
- async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
3557
- const options = typeof dependencyNameOrOptions === 'string'
3558
- ? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
3559
- : dependencyNameOrOptions;
3560
- const dependencyName = options.dependencyName;
3561
- try {
3562
- return await loader();
3563
- }
3564
- catch (error) {
3565
- if (isModuleNotFoundError(error)) {
3566
- const message = options.helpMessage ??
3567
- `Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
3568
- const enrichedError = new Error(message);
3569
- try {
3570
- enrichedError.cause = error;
3571
- }
3572
- catch {
3573
- // Ignore environments that do not support attaching a cause.
3574
- }
3575
- throw enrichedError;
3576
- }
3577
- throw error;
3578
- }
3579
- }
3580
-
3581
3582
  const indexedDBConfigSchema = z
3582
3583
  .object({
3583
3584
  type: z
@@ -7173,9 +7174,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
7173
7174
  this.ackDoneSince = new Map();
7174
7175
  this.replyDoneSince = new Map();
7175
7176
  this.pendingAckDispatches = new Set();
7176
- this.recentlyHandled = new Map();
7177
- this.recentlyHandledOrder = [];
7178
- this.recentlyHandledTtlMs = 60000;
7179
7177
  this.isPreparingToStop = false;
7180
7178
  this.shutdownRequestedAtMs = null;
7181
7179
  this.shutdownRetryGraceMs = 1000;
@@ -7397,22 +7395,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
7397
7395
  }
7398
7396
  }
7399
7397
  else {
7400
- const wasRecentlyHandled = await this.lock.runExclusive(async () => this.wasRecentlyHandled(envelope.id));
7401
- if (wasRecentlyHandled) {
7402
- logger$12.debug('tracker_duplicate_envelope_recently_handled', {
7403
- envp_id: envelope.id,
7404
- });
7405
- return new TrackedEnvelope({
7406
- timeoutAtMs: 0,
7407
- overallTimeoutAtMs: 0,
7408
- expectedResponseType: envelope.rtype ?? FameResponseType.NONE,
7409
- createdAtMs: Date.now(),
7410
- status: EnvelopeStatus.HANDLED,
7411
- mailboxType: MailboxType.INBOX,
7412
- originalEnvelope: envelope,
7413
- serviceName: inboxName,
7414
- });
7415
- }
7416
7398
  tracked = new TrackedEnvelope({
7417
7399
  timeoutAtMs: 0,
7418
7400
  overallTimeoutAtMs: 0,
@@ -7434,12 +7416,8 @@ class DefaultDeliveryTracker extends TaskSpawner {
7434
7416
  async onEnvelopeHandled(envelope) {
7435
7417
  const inbox = this.ensureInbox();
7436
7418
  envelope.status = EnvelopeStatus.HANDLED;
7419
+ // Delete the envelope from inbox to prevent growth
7437
7420
  await inbox.delete(envelope.originalEnvelope.id);
7438
- await this.lock.runExclusive(async () => {
7439
- this.markRecentlyHandled(envelope.originalEnvelope.id);
7440
- });
7441
- // Preserve handled envelope to prevent duplicate redelivery during shutdown drains.
7442
- // await inbox.set(envelope.originalEnvelope.id, envelope);
7443
7421
  }
7444
7422
  async onEnvelopeHandleFailed(inboxName, envelope, context, error, isFinalFailure = false) {
7445
7423
  const inbox = this.ensureInbox();
@@ -7654,9 +7632,9 @@ class DefaultDeliveryTracker extends TaskSpawner {
7654
7632
  });
7655
7633
  await this.markDoneSince(this.replyFutures, trackedEnvelope.originalEnvelope.id, this.replyDoneSince);
7656
7634
  await this.markDoneSince(this.ackFutures, trackedEnvelope.originalEnvelope.id, this.ackDoneSince);
7657
- if (envelope.rtype && Boolean(envelope.rtype & FameResponseType.ACK)) {
7658
- await this.sendAck(envelope);
7659
- }
7635
+ // Note: ACK is already sent in onCorrelatedMessage (lines 655-657)
7636
+ // when the reply envelope is first delivered. No need to send it again here.
7637
+ // Removing this duplicate sendAck call fixes the duplicate DeliveryAck bug.
7660
7638
  for (const handler of this.eventHandlers) {
7661
7639
  await handler.onEnvelopeReplied?.(trackedEnvelope, envelope);
7662
7640
  }
@@ -7806,8 +7784,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
7806
7784
  }
7807
7785
  this.streamDone.clear();
7808
7786
  this.correlationToEnvelope.clear();
7809
- this.recentlyHandled.clear();
7810
- this.recentlyHandledOrder.length = 0;
7811
7787
  return values;
7812
7788
  });
7813
7789
  for (const timer of timers) {
@@ -8389,39 +8365,6 @@ class DefaultDeliveryTracker extends TaskSpawner {
8389
8365
  this.pendingAckDispatches.delete(ackDispatch);
8390
8366
  }
8391
8367
  }
8392
- markRecentlyHandled(envelopeId) {
8393
- const now = Date.now();
8394
- this.recentlyHandled.set(envelopeId, now);
8395
- this.recentlyHandledOrder.push(envelopeId);
8396
- this.trimRecentlyHandled(now);
8397
- }
8398
- wasRecentlyHandled(envelopeId) {
8399
- const now = Date.now();
8400
- const timestamp = this.recentlyHandled.get(envelopeId);
8401
- if (timestamp === undefined) {
8402
- return false;
8403
- }
8404
- if (now - timestamp > this.recentlyHandledTtlMs) {
8405
- this.recentlyHandled.delete(envelopeId);
8406
- return false;
8407
- }
8408
- return true;
8409
- }
8410
- trimRecentlyHandled(now) {
8411
- while (this.recentlyHandledOrder.length > 0) {
8412
- const candidate = this.recentlyHandledOrder[0];
8413
- const timestamp = this.recentlyHandled.get(candidate);
8414
- if (timestamp === undefined) {
8415
- this.recentlyHandledOrder.shift();
8416
- continue;
8417
- }
8418
- if (now - timestamp <= this.recentlyHandledTtlMs) {
8419
- break;
8420
- }
8421
- this.recentlyHandled.delete(candidate);
8422
- this.recentlyHandledOrder.shift();
8423
- }
8424
- }
8425
8368
  getShutdownRetryDeferDelay(nowMs) {
8426
8369
  if (!this.isPreparingToStop || this.shutdownRequestedAtMs === null) {
8427
8370
  return null;
@@ -9915,7 +9858,8 @@ const ensureBroadcastEnvironment = () => {
9915
9858
  };
9916
9859
  let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAsyncConnector {
9917
9860
  static generateConnectorId() {
9918
- const globalCrypto = globalThis.crypto;
9861
+ const globalCrypto = globalThis
9862
+ .crypto;
9919
9863
  if (globalCrypto?.randomUUID) {
9920
9864
  return globalCrypto.randomUUID();
9921
9865
  }
@@ -9970,7 +9914,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9970
9914
  this.listenerRegistered = false;
9971
9915
  this.visibilityChangeListenerRegistered = false;
9972
9916
  this.channelName =
9973
- typeof config.channelName === 'string' && config.channelName.trim().length > 0
9917
+ typeof config.channelName === 'string' &&
9918
+ config.channelName.trim().length > 0
9974
9919
  ? config.channelName.trim()
9975
9920
  : DEFAULT_CHANNEL$7;
9976
9921
  const preferredCapacity = typeof config.inboxCapacity === 'number' &&
@@ -9994,6 +9939,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9994
9939
  local_node_id: this.localNodeId,
9995
9940
  target_node_id: this.targetNodeId ?? null,
9996
9941
  inbox_capacity: preferredCapacity,
9942
+ passive: config.passive ?? false,
9997
9943
  timestamp: new Date().toISOString(),
9998
9944
  });
9999
9945
  this.onMsg = (event) => {
@@ -10011,7 +9957,8 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10011
9957
  channel: this.channelName,
10012
9958
  connector_id: this.connectorId,
10013
9959
  message_type: message && typeof message === 'object'
10014
- ? message.constructor?.name ?? typeof message
9960
+ ? (message.constructor
9961
+ ?.name ?? typeof message)
10015
9962
  : typeof message,
10016
9963
  has_sender_id: Boolean(message?.senderId),
10017
9964
  has_sender_node_id: Boolean(message?.senderNodeId),
@@ -10241,7 +10188,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10241
10188
  timestamp: new Date().toISOString(),
10242
10189
  });
10243
10190
  }
10244
- if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
10191
+ if (this.visibilityChangeListenerRegistered &&
10192
+ this.visibilityChangeHandler &&
10193
+ typeof document !== 'undefined') {
10245
10194
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
10246
10195
  this.visibilityChangeListenerRegistered = false;
10247
10196
  this.visibilityChangeHandler = undefined;
@@ -10269,7 +10218,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10269
10218
  return rawOrEnvelope;
10270
10219
  }
10271
10220
  _isWildcardTarget() {
10272
- return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
10221
+ return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
10273
10222
  }
10274
10223
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
10275
10224
  if (this._isWildcardTarget()) {
@@ -10289,7 +10238,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10289
10238
  return true;
10290
10239
  }
10291
10240
  const expectedSender = this.targetNodeId;
10292
- if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
10241
+ if (expectedSender &&
10242
+ expectedSender !== '*' &&
10243
+ senderNodeId !== expectedSender) {
10293
10244
  logger$_.debug('broadcast_channel_message_rejected', {
10294
10245
  channel: this.channelName,
10295
10246
  connector_id: this.connectorId,
@@ -10508,14 +10459,16 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10508
10459
  type,
10509
10460
  purpose,
10510
10461
  };
10511
- const channelValue = candidate.channelName ?? candidate['channel_name'];
10462
+ const channelValue = candidate.channelName ??
10463
+ candidate['channel_name'];
10512
10464
  if (channelValue !== undefined) {
10513
10465
  if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
10514
10466
  throw new TypeError('BroadcastChannelConnectionGrant "channelName" must be a non-empty string when provided');
10515
10467
  }
10516
10468
  result.channelName = channelValue.trim();
10517
10469
  }
10518
- const inboxValue = candidate.inboxCapacity ?? candidate['inbox_capacity'];
10470
+ const inboxValue = candidate.inboxCapacity ??
10471
+ candidate['inbox_capacity'];
10519
10472
  if (inboxValue !== undefined) {
10520
10473
  if (typeof inboxValue !== 'number' ||
10521
10474
  !Number.isFinite(inboxValue) ||
@@ -10524,7 +10477,8 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10524
10477
  }
10525
10478
  result.inboxCapacity = Math.floor(inboxValue);
10526
10479
  }
10527
- const windowValue = candidate.initialWindow ?? candidate['initial_window'];
10480
+ const windowValue = candidate.initialWindow ??
10481
+ candidate['initial_window'];
10528
10482
  if (windowValue !== undefined) {
10529
10483
  if (typeof windowValue !== 'number' ||
10530
10484
  !Number.isFinite(windowValue) ||
@@ -10861,25 +10815,56 @@ class UpstreamSessionManager extends TaskSpawner {
10861
10815
  await connector.start(this.wrappedHandler);
10862
10816
  this.connector = connector;
10863
10817
  const callbackGrants = this.node.gatherSupportedCallbackGrants();
10818
+ logger$Z.debug('callback_grants_before_augmentation', {
10819
+ count: callbackGrants.length,
10820
+ types: callbackGrants.map((g) => g.type),
10821
+ });
10822
+ // Check if we should create a broadcast callback grant before processing connection grants
10823
+ // This prevents adding duplicate broadcast grants
10824
+ const shouldAddBroadcastGrant = this.shouldAdvertiseBroadcastGrant(grant, callbackGrants);
10825
+ const broadcastCallbackGrant = shouldAddBroadcastGrant
10826
+ ? this.createBroadcastCallbackGrant(grant)
10827
+ : null;
10828
+ logger$Z.debug('broadcast_callback_grant_check', {
10829
+ should_add: shouldAddBroadcastGrant,
10830
+ grant_created: !!broadcastCallbackGrant,
10831
+ });
10864
10832
  // Include admission client's connection grants as callback grants
10865
10833
  // This ensures DirectAdmissionClient grants are available for grant selection
10866
- if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
10834
+ if (welcome.frame.connectionGrants &&
10835
+ Array.isArray(welcome.frame.connectionGrants)) {
10867
10836
  for (const grant of welcome.frame.connectionGrants) {
10868
10837
  if (grant && typeof grant === 'object') {
10869
10838
  // Avoid duplicates by checking if grant already exists
10870
- const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
10839
+ const isDuplicate = callbackGrants.some((existing) => JSON.stringify(existing) === JSON.stringify(grant));
10871
10840
  if (!isDuplicate) {
10872
10841
  callbackGrants.push(grant);
10842
+ logger$Z.debug('added_connection_grant_as_callback', {
10843
+ type: grant.type,
10844
+ });
10845
+ }
10846
+ else {
10847
+ logger$Z.debug('skipped_duplicate_connection_grant', {
10848
+ type: grant.type,
10849
+ });
10873
10850
  }
10874
10851
  }
10875
10852
  }
10876
10853
  }
10877
- if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
10878
- const augmented = this.createBroadcastCallbackGrant(grant);
10879
- if (augmented) {
10880
- callbackGrants.push(augmented);
10881
- }
10854
+ // Add broadcast grant after connection grants to ensure we don't duplicate
10855
+ // any broadcast grants that may have been in connectionGrants
10856
+ if (broadcastCallbackGrant &&
10857
+ this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
10858
+ callbackGrants.push(broadcastCallbackGrant);
10859
+ logger$Z.debug('added_broadcast_callback_grant');
10882
10860
  }
10861
+ else if (broadcastCallbackGrant) {
10862
+ logger$Z.debug('skipped_duplicate_broadcast_callback_grant');
10863
+ }
10864
+ logger$Z.debug('callback_grants_after_augmentation', {
10865
+ count: callbackGrants.length,
10866
+ types: callbackGrants.map((g) => g.type),
10867
+ });
10883
10868
  const attachInfo = await this.attachClient.attach(this.node, this.outboundOriginType, connector, welcome.frame, this.wrappedHandler, this.getKeys() ?? undefined, callbackGrants);
10884
10869
  this.targetSystemId = attachInfo.targetSystemId ?? null;
10885
10870
  if (this.targetSystemId) {
@@ -11120,7 +11105,8 @@ class UpstreamSessionManager extends TaskSpawner {
11120
11105
  continue;
11121
11106
  }
11122
11107
  // Reset ack time if just resumed from pause (prevents immediate timeout)
11123
- if (previousState === ConnectorState.PAUSED && currentState === ConnectorState.STARTED) {
11108
+ if (previousState === ConnectorState.PAUSED &&
11109
+ currentState === ConnectorState.STARTED) {
11124
11110
  logger$Z.debug('connector_just_resumed_resetting_ack_time', {
11125
11111
  previous_state: previousState,
11126
11112
  current_state: currentState,
@@ -12677,15 +12663,30 @@ class DefaultNodeAttachClient {
12677
12663
  constructor(options = {}) {
12678
12664
  this.buffer = [];
12679
12665
  this.inHandshake = false;
12666
+ this.expectedSystemId = null;
12680
12667
  this.timeoutMs = options.timeoutMs ?? 10000;
12681
12668
  this.attachmentKeyValidator = options.attachmentKeyValidator;
12682
12669
  this.replicaStickinessManager = options.replicaStickinessManager ?? null;
12683
12670
  }
12684
12671
  async attach(node, originType, connector, welcomeFrame, finalHandler, keys, callbackGrants) {
12685
12672
  this.inHandshake = true;
12673
+ this.expectedSystemId = welcomeFrame.systemId;
12686
12674
  const interimHandler = async (envelope, context) => {
12687
12675
  if (this.inHandshake) {
12688
- this.buffer.push(envelope);
12676
+ // Filter: only buffer frames related to our systemId or frames without systemId info
12677
+ const frameSystemId = envelope.frame
12678
+ ?.systemId;
12679
+ if (!frameSystemId || frameSystemId === this.expectedSystemId) {
12680
+ this.buffer.push(envelope);
12681
+ }
12682
+ else {
12683
+ // Silently ignore frames from other agents during concurrent handshakes
12684
+ logger$W.debug('handshake_ignoring_frame_from_different_system', {
12685
+ frame_type: envelope.frame.type,
12686
+ frame_system_id: frameSystemId,
12687
+ expected_system_id: this.expectedSystemId,
12688
+ });
12689
+ }
12689
12690
  return null;
12690
12691
  }
12691
12692
  return finalHandler(envelope, context);
@@ -12812,6 +12813,7 @@ class DefaultNodeAttachClient {
12812
12813
  parent_id: ackFrame.targetSystemId,
12813
12814
  });
12814
12815
  this.inHandshake = false;
12816
+ this.expectedSystemId = null;
12815
12817
  await connector.replaceHandler(finalHandler);
12816
12818
  while (this.buffer.length > 0) {
12817
12819
  const bufferedEnvelope = this.buffer.shift();
@@ -12869,7 +12871,8 @@ class DefaultNodeAttachClient {
12869
12871
  const deadline = Date.now() + this.timeoutMs;
12870
12872
  while (Date.now() < deadline) {
12871
12873
  // Allow both STARTED and PAUSED states (PAUSED = tab hidden but connection alive)
12872
- if (connector.state !== ConnectorState.STARTED && connector.state !== ConnectorState.PAUSED) {
12874
+ if (connector.state !== ConnectorState.STARTED &&
12875
+ connector.state !== ConnectorState.PAUSED) {
12873
12876
  let errorMessage = 'Connector closed while waiting for NodeAttachAck';
12874
12877
  if (connector.closeCode !== undefined) {
12875
12878
  errorMessage += ` (code=${connector.closeCode}`;
@@ -12888,9 +12891,21 @@ class DefaultNodeAttachClient {
12888
12891
  if (envelope.frame.type === 'NodeAttachAck') {
12889
12892
  return envelope;
12890
12893
  }
12891
- logger$W.error('unexpected_frame_during_handshake', {
12892
- frame_type: envelope.frame.type,
12893
- });
12894
+ // NodeAttach frames during handshake are expected in multi-agent scenarios
12895
+ // where multiple agents attach concurrently to the same channel
12896
+ if (envelope.frame.type === 'NodeAttach') {
12897
+ logger$W.debug('handshake_ignoring_concurrent_attach', {
12898
+ frame_type: envelope.frame.type,
12899
+ frame_system_id: envelope.frame?.systemId ??
12900
+ 'unknown',
12901
+ });
12902
+ }
12903
+ else {
12904
+ // Other unexpected frames are still logged as errors
12905
+ logger$W.error('unexpected_frame_during_handshake', {
12906
+ frame_type: envelope.frame.type,
12907
+ });
12908
+ }
12894
12909
  }
12895
12910
  await delay(HANDSHAKE_POLL_INTERVAL_MS);
12896
12911
  }
@@ -13609,7 +13624,8 @@ function createFsShim() {
13609
13624
  else if (options &&
13610
13625
  typeof options === 'object' &&
13611
13626
  'encoding' in options &&
13612
- typeof options.encoding === 'string') {
13627
+ typeof options.encoding ===
13628
+ 'string') {
13613
13629
  encoding = options.encoding;
13614
13630
  }
13615
13631
  const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
@@ -20542,7 +20558,8 @@ class InPageConnector extends BaseAsyncConnector {
20542
20558
  this.listenerRegistered = false;
20543
20559
  this.visibilityChangeListenerRegistered = false;
20544
20560
  this.channelName =
20545
- typeof config.channelName === 'string' && config.channelName.trim().length > 0
20561
+ typeof config.channelName === 'string' &&
20562
+ config.channelName.trim().length > 0
20546
20563
  ? config.channelName.trim()
20547
20564
  : DEFAULT_CHANNEL$6;
20548
20565
  const preferredCapacity = typeof config.inboxCapacity === 'number' &&
@@ -20581,7 +20598,8 @@ class InPageConnector extends BaseAsyncConnector {
20581
20598
  channel: this.channelName,
20582
20599
  connector_id: this.connectorId,
20583
20600
  message_type: message && typeof message === 'object'
20584
- ? message.constructor?.name ?? typeof message
20601
+ ? (message.constructor
20602
+ ?.name ?? typeof message)
20585
20603
  : typeof message,
20586
20604
  has_sender_id: Boolean(message?.senderId),
20587
20605
  has_sender_node_id: Boolean(message?.senderNodeId),
@@ -20590,7 +20608,8 @@ class InPageConnector extends BaseAsyncConnector {
20590
20608
  return;
20591
20609
  }
20592
20610
  const busMessage = message;
20593
- const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
20611
+ const senderId = typeof busMessage.senderId === 'string' &&
20612
+ busMessage.senderId.length > 0
20594
20613
  ? busMessage.senderId
20595
20614
  : null;
20596
20615
  const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
@@ -20841,7 +20860,9 @@ class InPageConnector extends BaseAsyncConnector {
20841
20860
  timestamp: new Date().toISOString(),
20842
20861
  });
20843
20862
  }
20844
- if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
20863
+ if (this.visibilityChangeListenerRegistered &&
20864
+ this.visibilityChangeHandler &&
20865
+ typeof document !== 'undefined') {
20845
20866
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
20846
20867
  this.visibilityChangeListenerRegistered = false;
20847
20868
  this.visibilityChangeHandler = undefined;
@@ -20858,7 +20879,7 @@ class InPageConnector extends BaseAsyncConnector {
20858
20879
  return rawOrEnvelope;
20859
20880
  }
20860
20881
  _isWildcardTarget() {
20861
- return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
20882
+ return (this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined');
20862
20883
  }
20863
20884
  _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
20864
20885
  if (this._isWildcardTarget()) {
@@ -20878,7 +20899,9 @@ class InPageConnector extends BaseAsyncConnector {
20878
20899
  return true;
20879
20900
  }
20880
20901
  const expectedSender = this.targetNodeId;
20881
- if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
20902
+ if (expectedSender &&
20903
+ expectedSender !== '*' &&
20904
+ senderNodeId !== expectedSender) {
20882
20905
  logger$G.debug('inpage_message_rejected', {
20883
20906
  channel: this.channelName,
20884
20907
  connector_id: this.connectorId,
@@ -21298,8 +21321,8 @@ class CertificateManagerFactory extends AbstractResourceFactory {
21298
21321
  }
21299
21322
  }
21300
21323
 
21301
- 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.";
21302
- const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = "TrustStoreProviderFactory";
21324
+ 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.';
21325
+ const TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE = 'TrustStoreProviderFactory';
21303
21326
  class TrustStoreProviderFactory extends AbstractResourceFactory {
21304
21327
  createUnconfiguredProvider(reason) {
21305
21328
  return new NoopTrustStoreProvider(reason ?? DEFAULT_UNCONFIGURED_MESSAGE);
@@ -25027,7 +25050,8 @@ class DefaultSecurityManager {
25027
25050
  const hasSignature = Boolean(envelope.sec?.sig);
25028
25051
  if (!hasSignature) {
25029
25052
  const nodeSid = node.sid;
25030
- const envelopeSid = envelope.sid;
25053
+ const envelopeSid = envelope
25054
+ .sid;
25031
25055
  const isLocalUnsignedSelfEnvelope = localContext.originType === DeliveryOriginType.LOCAL &&
25032
25056
  typeof nodeSid === 'string' &&
25033
25057
  nodeSid.length > 0 &&
@@ -28307,14 +28331,16 @@ function normalizeInPageConnectionGrant(candidate) {
28307
28331
  type,
28308
28332
  purpose,
28309
28333
  };
28310
- const channelValue = candidate.channelName ?? candidate['channel_name'];
28334
+ const channelValue = candidate.channelName ??
28335
+ candidate['channel_name'];
28311
28336
  if (channelValue !== undefined) {
28312
28337
  if (typeof channelValue !== 'string' || channelValue.trim().length === 0) {
28313
28338
  throw new TypeError('InPageConnectionGrant "channelName" must be a non-empty string when provided');
28314
28339
  }
28315
28340
  result.channelName = channelValue.trim();
28316
28341
  }
28317
- const inboxValue = candidate.inboxCapacity ?? candidate['inbox_capacity'];
28342
+ const inboxValue = candidate.inboxCapacity ??
28343
+ candidate['inbox_capacity'];
28318
28344
  if (inboxValue !== undefined) {
28319
28345
  if (typeof inboxValue !== 'number' ||
28320
28346
  !Number.isFinite(inboxValue) ||
@@ -28942,7 +28968,8 @@ class InPageConnectorFactory extends ConnectorFactory {
28942
28968
  const normalized = this._normalizeConfig(config);
28943
28969
  const options = (factoryArgs[0] ?? {});
28944
28970
  const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28945
- const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28971
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ??
28972
+ normalizedLocalNodeFromConfig;
28946
28973
  if (!localNodeId) {
28947
28974
  throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
28948
28975
  }
@@ -29118,10 +29145,12 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29118
29145
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
29119
29146
  };
29120
29147
  const channelCandidate = record.channelName ?? record['channel_name'];
29121
- if (typeof channelCandidate === 'string' && channelCandidate.trim().length > 0) {
29148
+ if (typeof channelCandidate === 'string' &&
29149
+ channelCandidate.trim().length > 0) {
29122
29150
  config.channelName = channelCandidate.trim();
29123
29151
  }
29124
- const inboxCandidate = record.inboxCapacity ?? record['inbox_capacity'];
29152
+ const inboxCandidate = record.inboxCapacity ??
29153
+ record['inbox_capacity'];
29125
29154
  if (typeof inboxCandidate === 'number' &&
29126
29155
  Number.isFinite(inboxCandidate) &&
29127
29156
  inboxCandidate > 0) {
@@ -29145,9 +29174,11 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29145
29174
  throw new Error('BroadcastChannelConnectorFactory requires a configuration');
29146
29175
  }
29147
29176
  const normalized = this._normalizeConfig(config);
29148
- const options = (factoryArgs[0] ?? {});
29177
+ const options = (factoryArgs[0] ??
29178
+ {});
29149
29179
  const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
29150
- const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
29180
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ??
29181
+ normalizedLocalNodeFromConfig;
29151
29182
  if (!localNodeId) {
29152
29183
  throw new Error('BroadcastChannelConnectorFactory requires a localNodeId from config or create() options');
29153
29184
  }
@@ -29172,6 +29203,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29172
29203
  inboxCapacity,
29173
29204
  localNodeId,
29174
29205
  initialTargetNodeId: resolvedTarget,
29206
+ passive: normalized.passive,
29175
29207
  };
29176
29208
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
29177
29209
  if (options.authorization) {
@@ -29210,6 +29242,9 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
29210
29242
  if (normalizedLocalNodeId) {
29211
29243
  normalized.localNodeId = normalizedLocalNodeId;
29212
29244
  }
29245
+ if (typeof candidate.passive === 'boolean') {
29246
+ normalized.passive = candidate.passive;
29247
+ }
29213
29248
  if (typeof candidate.flowControl === 'boolean') {
29214
29249
  normalized.flowControl = candidate.flowControl;
29215
29250
  }
@@ -29635,7 +29670,9 @@ class InPageListener extends TransportListener {
29635
29670
  typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
29636
29671
  ? channelCandidate.trim()
29637
29672
  : DEFAULT_CHANNEL$3;
29638
- const normalizedCapacity = typeof inboxCandidate === 'number' && Number.isFinite(inboxCandidate) && inboxCandidate > 0
29673
+ const normalizedCapacity = typeof inboxCandidate === 'number' &&
29674
+ Number.isFinite(inboxCandidate) &&
29675
+ inboxCandidate > 0
29639
29676
  ? Math.floor(inboxCandidate)
29640
29677
  : DEFAULT_INBOX_CAPACITY$3;
29641
29678
  this._inboxCapacity = normalizedCapacity;
@@ -29910,7 +29947,8 @@ class InPageListener extends TransportListener {
29910
29947
  if (grant.type === INPAGE_CONNECTION_GRANT_TYPE) {
29911
29948
  return inPageGrantToConnectorConfig(grant);
29912
29949
  }
29913
- if (typeof grant?.toConnectorConfig === 'function') {
29950
+ if (typeof grant
29951
+ ?.toConnectorConfig === 'function') {
29914
29952
  return grant.toConnectorConfig();
29915
29953
  }
29916
29954
  throw new Error(`Unsupported grant type: ${grant.type}`);
@@ -30064,7 +30102,9 @@ function normalizeConfig$r(config) {
30064
30102
  : DEFAULT_CHANNEL$2;
30065
30103
  const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
30066
30104
  let inboxCapacity = DEFAULT_INBOX_CAPACITY$2;
30067
- if (typeof rawInbox === 'number' && Number.isFinite(rawInbox) && rawInbox > 0) {
30105
+ if (typeof rawInbox === 'number' &&
30106
+ Number.isFinite(rawInbox) &&
30107
+ rawInbox > 0) {
30068
30108
  inboxCapacity = Math.floor(rawInbox);
30069
30109
  }
30070
30110
  else if (typeof rawInbox === 'string') {
@@ -30092,9 +30132,7 @@ class InPageListenerFactory extends TransportListenerFactory {
30092
30132
  }
30093
30133
  async create(config, ...factoryArgs) {
30094
30134
  const normalized = normalizeConfig$r(config);
30095
- const [{ InPageListener }] = await Promise.all([
30096
- getInPageListenerModule(),
30097
- ]);
30135
+ const [{ InPageListener }] = await Promise.all([getInPageListenerModule()]);
30098
30136
  return new InPageListener({
30099
30137
  channelName: normalized.channelName,
30100
30138
  inboxCapacity: normalized.inboxCapacity,
@@ -30112,9 +30150,7 @@ var inpageListenerFactory = /*#__PURE__*/Object.freeze({
30112
30150
  const logger$o = getLogger('naylence.fame.connector.broadcast_channel_listener');
30113
30151
  const DEFAULT_CHANNEL$1 = 'naylence-fabric';
30114
30152
  const DEFAULT_INBOX_CAPACITY$1 = 2048;
30115
- const RESPONSE_TYPE_MASK = FameResponseType.ACK |
30116
- FameResponseType.REPLY |
30117
- FameResponseType.STREAM;
30153
+ const RESPONSE_TYPE_MASK = FameResponseType.ACK | FameResponseType.REPLY | FameResponseType.STREAM;
30118
30154
  const isBrowserEnvironment$1 = () => typeof window !== 'undefined' &&
30119
30155
  typeof BroadcastChannel !== 'undefined' &&
30120
30156
  typeof MessageEvent !== 'undefined';
@@ -30328,9 +30364,7 @@ class BroadcastChannelListener extends TransportListener {
30328
30364
  return null;
30329
30365
  }
30330
30366
  })();
30331
- if (error instanceof ZodError &&
30332
- decoded &&
30333
- decoded.length > 0) {
30367
+ if (error instanceof ZodError && decoded && decoded.length > 0) {
30334
30368
  try {
30335
30369
  const reparsed = JSON.parse(decoded);
30336
30370
  const candidate = reparsed.rtype;
@@ -30553,11 +30587,19 @@ class BroadcastChannelListener extends TransportListener {
30553
30587
  ? Math.floor(initialWindowCandidate)
30554
30588
  : undefined;
30555
30589
  const initialTargetNodeId = this._normalizeNodeId(targetCandidate) ?? targetSystemId;
30590
+ const passive = typeof passiveCandidate === 'boolean' ? passiveCandidate : true;
30591
+ logger$o.debug('broadcast_channel_listener_building_connector_config', {
30592
+ system_id: systemId,
30593
+ channel_name: channelName,
30594
+ passive,
30595
+ has_base_config: !!baseConfig,
30596
+ passive_candidate: passiveCandidate,
30597
+ });
30556
30598
  return {
30557
30599
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
30558
30600
  channelName,
30559
30601
  inboxCapacity,
30560
- passive: typeof passiveCandidate === 'boolean' ? passiveCandidate : true,
30602
+ passive,
30561
30603
  initialWindow,
30562
30604
  localNodeId,
30563
30605
  initialTargetNodeId,
@@ -30670,7 +30712,9 @@ function normalizeConfig$q(config) {
30670
30712
  : DEFAULT_CHANNEL;
30671
30713
  const rawInbox = record.inboxCapacity ?? record['inbox_capacity'];
30672
30714
  let inboxCapacity = DEFAULT_INBOX_CAPACITY;
30673
- if (typeof rawInbox === 'number' && Number.isFinite(rawInbox) && rawInbox > 0) {
30715
+ if (typeof rawInbox === 'number' &&
30716
+ Number.isFinite(rawInbox) &&
30717
+ rawInbox > 0) {
30674
30718
  inboxCapacity = Math.floor(rawInbox);
30675
30719
  }
30676
30720
  else if (typeof rawInbox === 'string') {
@@ -34160,19 +34204,23 @@ function normalizeConfig$a(config) {
34160
34204
  normalized.clientSecretConfig = normalizeSecretSource(clientSecretSource);
34161
34205
  }
34162
34206
  const audienceCandidate = candidate.audience ?? candidate.aud;
34163
- if (typeof audienceCandidate === 'string' && audienceCandidate.trim().length > 0) {
34207
+ if (typeof audienceCandidate === 'string' &&
34208
+ audienceCandidate.trim().length > 0) {
34164
34209
  normalized.audience = audienceCandidate.trim();
34165
34210
  }
34166
34211
  const codeChallengeMethod = candidate.codeChallengeMethod ?? candidate.code_challenge_method;
34167
- if (typeof codeChallengeMethod === 'string' && codeChallengeMethod.trim().length > 0) {
34212
+ if (typeof codeChallengeMethod === 'string' &&
34213
+ codeChallengeMethod.trim().length > 0) {
34168
34214
  normalized.codeChallengeMethod = codeChallengeMethod.trim();
34169
34215
  }
34170
34216
  const codeVerifierLength = candidate.codeVerifierLength ?? candidate.code_verifier_length;
34171
- if (typeof codeVerifierLength === 'number' && Number.isFinite(codeVerifierLength)) {
34217
+ if (typeof codeVerifierLength === 'number' &&
34218
+ Number.isFinite(codeVerifierLength)) {
34172
34219
  normalized.codeVerifierLength = codeVerifierLength;
34173
34220
  }
34174
34221
  const clockSkewSeconds = candidate.clockSkewSeconds ?? candidate.clock_skew_seconds;
34175
- if (typeof clockSkewSeconds === 'number' && Number.isFinite(clockSkewSeconds)) {
34222
+ if (typeof clockSkewSeconds === 'number' &&
34223
+ Number.isFinite(clockSkewSeconds)) {
34176
34224
  normalized.clockSkewSeconds = clockSkewSeconds;
34177
34225
  }
34178
34226
  const loginHintParam = candidate.loginHintParam ?? candidate.login_hint_param;
@@ -34217,8 +34265,8 @@ class OAuth2PkceTokenProviderFactory extends TokenProviderFactory {
34217
34265
  options.audience = normalized.audience;
34218
34266
  }
34219
34267
  if (normalized.codeChallengeMethod) {
34220
- options.codeChallengeMethod = normalized.codeChallengeMethod
34221
- .toUpperCase();
34268
+ options.codeChallengeMethod =
34269
+ normalized.codeChallengeMethod.toUpperCase();
34222
34270
  }
34223
34271
  if (normalized.codeVerifierLength) {
34224
34272
  options.codeVerifierLength = normalized.codeVerifierLength;
@@ -35975,14 +36023,14 @@ var eddsaEnvelopeVerifierFactory = /*#__PURE__*/Object.freeze({
35975
36023
 
35976
36024
  const FACTORY_META$d = {
35977
36025
  base: TRUST_STORE_PROVIDER_FACTORY_BASE_TYPE,
35978
- key: "NoopTrustStoreProvider",
36026
+ key: 'NoopTrustStoreProvider',
35979
36027
  isDefault: true,
35980
36028
  priority: 10,
35981
36029
  };
35982
36030
  class NoopTrustStoreProviderFactory extends TrustStoreProviderFactory {
35983
36031
  constructor() {
35984
36032
  super(...arguments);
35985
- this.type = "NoopTrustStoreProvider";
36033
+ this.type = 'NoopTrustStoreProvider';
35986
36034
  this.isDefault = true;
35987
36035
  this.priority = 10;
35988
36036
  }
@@ -39376,8 +39424,7 @@ function normalizeOptions$2(raw) {
39376
39424
  const scopes = normalizeScopes(camel.scopes) ??
39377
39425
  normalizeScopes(snake.scopes ?? snake.scope) ??
39378
39426
  DEFAULT_SCOPES.slice();
39379
- const audience = coerceString(camel.audience) ??
39380
- coerceString(snake.audience ?? snake.aud);
39427
+ const audience = coerceString(camel.audience) ?? coerceString(snake.audience ?? snake.aud);
39381
39428
  const fetchImpl = (camel.fetchImpl ?? snake.fetch_impl);
39382
39429
  const clockSkewSeconds = coerceNumber(camel.clockSkewSeconds) ??
39383
39430
  coerceNumber(snake.clock_skew_seconds) ??
@@ -40869,4 +40916,4 @@ var websocketTransportProvisioner = /*#__PURE__*/Object.freeze({
40869
40916
  WebSocketTransportProvisionerFactory: WebSocketTransportProvisionerFactory
40870
40917
  });
40871
40918
 
40872
- 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, FACTORY_META$Z as BROADCAST_CHANNEL_CONNECTOR_FACTORY_META, BROADCAST_CHANNEL_CONNECTOR_TYPE, FACTORY_META$X as BROADCAST_CHANNEL_LISTENER_FACTORY_META, BackPressureFull, BaseAsyncConnector, BaseNodeEventListener, BindingManager, BindingStoreEntryRecord, BroadcastChannelConnector, BroadcastChannelConnectorFactory, BroadcastChannelListener, BroadcastChannelListenerFactory, 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, FACTORY_META$_ as INPAGE_CONNECTOR_FACTORY_META, INPAGE_CONNECTOR_TYPE, FACTORY_META$Y as INPAGE_LISTENER_FACTORY_META, InMemoryBinding, InMemoryFanoutBroker, InMemoryKeyValueStore, InMemoryReadWriteChannel, InMemoryStorageProvider, InPageConnector, InPageConnectorFactory, InPageListener, InPageListenerFactory, 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 };
40919
+ 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, FACTORY_META$Z as BROADCAST_CHANNEL_CONNECTOR_FACTORY_META, BROADCAST_CHANNEL_CONNECTOR_TYPE, FACTORY_META$X as BROADCAST_CHANNEL_LISTENER_FACTORY_META, BackPressureFull, BaseAsyncConnector, BaseNodeEventListener, BindingManager, BindingStoreEntryRecord, BroadcastChannelConnector, BroadcastChannelConnectorFactory, BroadcastChannelListener, BroadcastChannelListenerFactory, 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, FACTORY_META$_ as INPAGE_CONNECTOR_FACTORY_META, INPAGE_CONNECTOR_TYPE, FACTORY_META$Y as INPAGE_LISTENER_FACTORY_META, InMemoryBinding, InMemoryFanoutBroker, InMemoryKeyValueStore, InMemoryReadWriteChannel, InMemoryStorageProvider, InPageConnector, InPageConnectorFactory, InPageListener, InPageListenerFactory, 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 };