@equinor/fusion-framework-vite-plugin-spa 4.0.7 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5218,6 +5218,79 @@ class BaseConfigBuilder {
5218
5218
  }
5219
5219
  }
5220
5220
 
5221
+ /**
5222
+ * Error thrown when a required module fails to initialize within the expected
5223
+ * timeout window.
5224
+ *
5225
+ * Indicates a circular dependency or a module that never resolves.
5226
+ */
5227
+ class RequiredModuleTimeoutError extends Error {
5228
+ constructor() {
5229
+ super('Module initialization timed out');
5230
+ this.name = 'RequiredModuleTimeoutError';
5231
+ }
5232
+ }
5233
+
5234
+ /** Shared base segment for module configurator lifecycle event names. */
5235
+ const ModuleConfiguratorEventBaseName = 'ModuleConfigurator';
5236
+ /**
5237
+ * Event names emitted by `ModulesConfigurator` and its lifecycle phase helpers.
5238
+ *
5239
+ * Use this map instead of inline string literals when emitting or filtering
5240
+ * configurator lifecycle events. Each value follows the
5241
+ * `ModuleConfigurator.{name}.{state}` convention. The emitted names are still
5242
+ * prefixed by `ModulesConfigurator::_registerEvent` at runtime.
5243
+ */
5244
+ const ModuleConfiguratorEventName = {
5245
+ ModuleConfigAdded: `${ModuleConfiguratorEventBaseName}.module.configAdded`,
5246
+ OnConfiguredAdded: `${ModuleConfiguratorEventBaseName}.onConfigured.added`,
5247
+ OnInitializedAdded: `${ModuleConfiguratorEventBaseName}.onInitialized.added`,
5248
+ PluginAdded: `${ModuleConfiguratorEventBaseName}.plugin.added`,
5249
+ InitializeConfigLoaded: `${ModuleConfiguratorEventBaseName}.config.loaded`,
5250
+ InitializeInstanceInitialized: `${ModuleConfiguratorEventBaseName}.instance.initialized`,
5251
+ Initialize: `${ModuleConfiguratorEventBaseName}.initialize.complete`,
5252
+ ConfiguratorCreated: `${ModuleConfiguratorEventBaseName}.configurator.created`,
5253
+ ConfiguratorFailed: `${ModuleConfiguratorEventBaseName}.configurator.failed`,
5254
+ ModulePostConfigured: `${ModuleConfiguratorEventBaseName}.module.postConfigured`,
5255
+ ModulePostConfigureError: `${ModuleConfiguratorEventBaseName}.module.postConfigureError`,
5256
+ PostConfigureHooks: `${ModuleConfiguratorEventBaseName}.postConfigureHooks.started`,
5257
+ PostConfigureHooksComplete: `${ModuleConfiguratorEventBaseName}.postConfigureHooks.complete`,
5258
+ PostConfigureHooksError: `${ModuleConfiguratorEventBaseName}.postConfigureHooks.error`,
5259
+ ModuleInitializeError: `${ModuleConfiguratorEventBaseName}.module.initializeError`,
5260
+ ModuleInitializing: `${ModuleConfiguratorEventBaseName}.module.initializing`,
5261
+ ProviderNotBaseModuleProvider: `${ModuleConfiguratorEventBaseName}.provider.invalidBase`,
5262
+ ProviderVersionWarning: `${ModuleConfiguratorEventBaseName}.provider.versionMissing`,
5263
+ ModuleInitialized: `${ModuleConfiguratorEventBaseName}.module.initialized`,
5264
+ RequireInstanceModuleNotDefined: `${ModuleConfiguratorEventBaseName}.requireInstance.moduleNotDefined`,
5265
+ RequireInstanceModuleAlreadyInitialized: `${ModuleConfiguratorEventBaseName}.requireInstance.moduleAlreadyInitialized`,
5266
+ RequireInstanceAwaitingModule: `${ModuleConfiguratorEventBaseName}.requireInstance.awaitingModule`,
5267
+ RequireInstanceTimeout: `${ModuleConfiguratorEventBaseName}.requireInstance.timeout`,
5268
+ RequireInstanceModuleResolved: `${ModuleConfiguratorEventBaseName}.requireInstance.moduleResolved`,
5269
+ ModuleInitializeComplete: `${ModuleConfiguratorEventBaseName}.modules.initializeComplete`,
5270
+ InitializeComplete: `${ModuleConfiguratorEventBaseName}.initialize.instanceComplete`,
5271
+ ConfiguratorPostInitializeStart: `${ModuleConfiguratorEventBaseName}.postInitialize.started`,
5272
+ ModulePostInitializeStart: `${ModuleConfiguratorEventBaseName}.modulePostInitialize.started`,
5273
+ ModulePostInitializeComplete: `${ModuleConfiguratorEventBaseName}.modulePostInitialize.complete`,
5274
+ ModulePostInitializeError: `${ModuleConfiguratorEventBaseName}.modulePostInitialize.error`,
5275
+ PostInitializeComplete: `${ModuleConfiguratorEventBaseName}.postInitialize.complete`,
5276
+ PostInitializeCompleteNoHooks: `${ModuleConfiguratorEventBaseName}.postInitialize.noHooks`,
5277
+ PostInitializeHooks: `${ModuleConfiguratorEventBaseName}.postInitializeHooks.started`,
5278
+ PostInitializeHooksComplete: `${ModuleConfiguratorEventBaseName}.postInitializeHooks.complete`,
5279
+ PostInitializeHooksError: `${ModuleConfiguratorEventBaseName}.postInitializeHooks.error`,
5280
+ PluginsRegister: `${ModuleConfiguratorEventBaseName}.plugins.registering`,
5281
+ PluginRegistered: `${ModuleConfiguratorEventBaseName}.plugin.registered`,
5282
+ PluginRegisterError: `${ModuleConfiguratorEventBaseName}.plugin.registerError`,
5283
+ PluginsRegistered: `${ModuleConfiguratorEventBaseName}.plugins.registered`,
5284
+ Dispose: `${ModuleConfiguratorEventBaseName}.dispose.started`,
5285
+ PluginsDisposing: `${ModuleConfiguratorEventBaseName}.plugins.disposing`,
5286
+ PluginDisposed: `${ModuleConfiguratorEventBaseName}.plugin.disposed`,
5287
+ PluginDisposeError: `${ModuleConfiguratorEventBaseName}.plugin.disposeError`,
5288
+ ModulesDispose: `${ModuleConfiguratorEventBaseName}.modules.disposing`,
5289
+ ModuleDisposed: `${ModuleConfiguratorEventBaseName}.module.disposed`,
5290
+ ModuleDisposeError: `${ModuleConfiguratorEventBaseName}.module.disposeError`,
5291
+ ModulesDisposed: `${ModuleConfiguratorEventBaseName}.modules.disposed`,
5292
+ };
5293
+
5221
5294
  /* eslint-disable @typescript-eslint/no-explicit-any */
5222
5295
  /**
5223
5296
  * Defines the severity levels for module events.
@@ -5238,6 +5311,170 @@ var ModuleEventLevel;
5238
5311
  ModuleEventLevel[ModuleEventLevel["Critical"] = 4] = "Critical";
5239
5312
  })(ModuleEventLevel || (ModuleEventLevel = {}));
5240
5313
 
5314
+ // biome-ignore-all lint/suspicious/noExplicitAny: internal type-erased dispatch — the configure phase coordinates opaque module configs without knowing their concrete shapes
5315
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5316
+ /**
5317
+ * Creates the raw module config map by calling each module's `configure` factory.
5318
+ *
5319
+ * Runs all module `configure(ref)` calls concurrently via `mergeMap` and
5320
+ * accumulates results into a single config object. The object is seeded with
5321
+ * `onAfterConfiguration` and `onAfterInit` helpers that allow modules to
5322
+ * register additional post-phase callbacks during configuration.
5323
+ *
5324
+ * @param ctx - The configure phase context.
5325
+ * @param ref - Optional reference forwarded to each module's configure factory.
5326
+ * @returns A promise resolving to the merged module config map.
5327
+ * @internal
5328
+ */
5329
+ async function createModuleConfigs(ctx, ref) {
5330
+ const { modules, afterConfiguration, afterInit, registerEvent } = ctx;
5331
+ const config$ = from(modules).pipe(mergeMap(async (module) => {
5332
+ const configStart = performance.now();
5333
+ try {
5334
+ const configurator = await module.configure?.(ref);
5335
+ const configLoadTime = Math.round(performance.now() - configStart);
5336
+ registerEvent({
5337
+ level: ModuleEventLevel.Debug,
5338
+ name: ModuleConfiguratorEventName.ConfiguratorCreated,
5339
+ message: `Configurator created for ${module.name} in ${configLoadTime}ms`,
5340
+ properties: {
5341
+ moduleName: module.name,
5342
+ moduleVersion: module.version?.toString() || 'unknown',
5343
+ configLoadTime,
5344
+ },
5345
+ metric: configLoadTime,
5346
+ });
5347
+ return { [module.name]: configurator };
5348
+ }
5349
+ catch (err) {
5350
+ registerEvent({
5351
+ level: ModuleEventLevel.Error,
5352
+ name: ModuleConfiguratorEventName.ConfiguratorFailed,
5353
+ message: `Failed to create configurator for ${module.name}`,
5354
+ properties: {
5355
+ moduleName: module.name,
5356
+ moduleVersion: module.version?.toString() || 'unknown',
5357
+ },
5358
+ metric: Math.round(performance.now() - configStart),
5359
+ error: err,
5360
+ });
5361
+ throw err;
5362
+ }
5363
+ }), reduce((acc, module) => Object.assign(acc, module),
5364
+ // Seed the config object with hooks so modules can register post-phase callbacks
5365
+ // during their own configure factory (a common pattern for cross-module wiring).
5366
+ {
5367
+ onAfterConfiguration(cb) {
5368
+ afterConfiguration.push(cb);
5369
+ },
5370
+ onAfterInit(cb) {
5371
+ afterInit.push(cb);
5372
+ },
5373
+ }));
5374
+ return lastValueFrom(config$);
5375
+ }
5376
+ /**
5377
+ * Runs the post-configure phase: calls each module's `postConfigure` hook and
5378
+ * then invokes all registered `afterConfiguration` callbacks.
5379
+ *
5380
+ * Module `postConfigure` failures are caught individually and emitted as
5381
+ * Warning events so one failing module cannot block others.
5382
+ *
5383
+ * @param ctx - The configure phase context.
5384
+ * @param config - The merged module config map produced by {@link createModuleConfigs}.
5385
+ * @returns A promise resolving when all post-configure hooks have settled.
5386
+ * @internal
5387
+ */
5388
+ async function runPostConfigureHooks(ctx, config) {
5389
+ const { modules, afterConfiguration, registerEvent } = ctx;
5390
+ // Run each module's postConfigure hook; failures are isolated so one
5391
+ // failing module does not prevent others from completing post-configure.
5392
+ await Promise.allSettled(modules
5393
+ .filter((module) => !!module.postConfigure)
5394
+ .map(async (module) => {
5395
+ try {
5396
+ const postConfigStart = performance.now();
5397
+ await module.postConfigure?.(config);
5398
+ registerEvent({
5399
+ level: ModuleEventLevel.Debug,
5400
+ name: ModuleConfiguratorEventName.ModulePostConfigured,
5401
+ message: `Module ${module.name} post-configured successfully`,
5402
+ properties: {
5403
+ moduleName: module.name,
5404
+ moduleVersion: module.version?.toString() || 'unknown',
5405
+ postConfigTime: Math.round(performance.now() - postConfigStart),
5406
+ },
5407
+ });
5408
+ }
5409
+ catch (err) {
5410
+ registerEvent({
5411
+ level: ModuleEventLevel.Warning,
5412
+ name: ModuleConfiguratorEventName.ModulePostConfigureError,
5413
+ message: `Module ${module.name} post-configure failed`,
5414
+ properties: {
5415
+ moduleName: module.name,
5416
+ moduleVersion: module.version?.toString() || 'unknown',
5417
+ },
5418
+ error: err,
5419
+ });
5420
+ }
5421
+ }));
5422
+ if (!afterConfiguration.length)
5423
+ return;
5424
+ // Run all registered afterConfiguration callbacks. These were added either
5425
+ // by addConfig's afterConfig or via config.onAfterConfiguration inside a
5426
+ // module's configure factory.
5427
+ try {
5428
+ registerEvent({
5429
+ level: ModuleEventLevel.Debug,
5430
+ name: ModuleConfiguratorEventName.PostConfigureHooks,
5431
+ message: `Post configure hooks [${afterConfiguration.length}] called`,
5432
+ });
5433
+ const postConfigHooksStart = performance.now();
5434
+ await Promise.allSettled(afterConfiguration.map((x) => Promise.resolve(x(config))));
5435
+ const postConfigHooksTime = Math.round(performance.now() - postConfigHooksStart);
5436
+ registerEvent({
5437
+ level: ModuleEventLevel.Debug,
5438
+ name: ModuleConfiguratorEventName.PostConfigureHooksComplete,
5439
+ message: 'Post configure hooks complete',
5440
+ properties: {
5441
+ count: afterConfiguration.length,
5442
+ postConfigHooksTime,
5443
+ },
5444
+ metric: postConfigHooksTime,
5445
+ });
5446
+ }
5447
+ catch (err) {
5448
+ registerEvent({
5449
+ level: ModuleEventLevel.Warning,
5450
+ name: ModuleConfiguratorEventName.PostConfigureHooksError,
5451
+ message: 'Post configure hook failed',
5452
+ error: err,
5453
+ });
5454
+ }
5455
+ }
5456
+ /**
5457
+ * Runs the full configure lifecycle phase for a set of modules.
5458
+ *
5459
+ * Orchestrates three sub-steps in order:
5460
+ * 1. {@link createModuleConfigs} — call each module's `configure(ref)` factory.
5461
+ * 2. Apply all user-registered config callbacks (`_configs`) sequentially.
5462
+ * 3. {@link runPostConfigureHooks} — call `postConfigure` and `afterConfiguration` hooks.
5463
+ *
5464
+ * @param ctx - The configure phase context.
5465
+ * @param ref - Optional reference forwarded through all configure hooks.
5466
+ * @returns A promise resolving to the fully configured module config map.
5467
+ */
5468
+ async function runConfigurePhase(ctx, ref) {
5469
+ // Step 1: Create raw config objects for all registered modules
5470
+ const config = await createModuleConfigs(ctx, ref);
5471
+ // Step 2: Apply all user-registered configuration callbacks concurrently.
5472
+ await Promise.all(ctx.configs.map((cb) => Promise.resolve(cb(config, ref))));
5473
+ // Step 3: Run module postConfigure hooks and afterConfiguration callbacks
5474
+ await runPostConfigureHooks(ctx, config);
5475
+ return config;
5476
+ }
5477
+
5241
5478
  /**
5242
5479
  * Abstract base class for Fusion Framework module providers.
5243
5480
  *
@@ -5325,37 +5562,624 @@ class BaseModuleProvider {
5325
5562
  }
5326
5563
  }
5327
5564
 
5328
- // Generated by genversion.
5329
- const version$8 = '6.0.0';
5565
+ /**
5566
+ * Initializes a single module and emits a `[name, instance]` tuple when complete.
5567
+ *
5568
+ * Validates that the module exposes an `initialize` method, calls it with the
5569
+ * provided context, and emits lifecycle events for start, completion, and any
5570
+ * provider contract warnings.
5571
+ *
5572
+ * @internal
5573
+ */
5574
+ async function initializeModule(module, ctx) {
5575
+ const { config, ref, requireInstance, hasModule, registerEvent } = ctx;
5576
+ const key = module.name;
5577
+ if (!module.initialize) {
5578
+ const error = new Error(`Module ${module.name} does not have initialize method`);
5579
+ error.name = 'ModuleInitializeError';
5580
+ registerEvent({
5581
+ level: ModuleEventLevel.Error,
5582
+ name: ModuleConfiguratorEventName.ModuleInitializeError,
5583
+ message: error.message,
5584
+ properties: {
5585
+ moduleName: module.name,
5586
+ moduleVersion: module.version?.toString() || 'unknown',
5587
+ },
5588
+ error,
5589
+ });
5590
+ throw error;
5591
+ }
5592
+ registerEvent({
5593
+ level: ModuleEventLevel.Debug,
5594
+ name: ModuleConfiguratorEventName.ModuleInitializing,
5595
+ message: `Initializing module ${module.name}`,
5596
+ properties: {
5597
+ moduleName: module.name,
5598
+ moduleVersion: module.version?.toString() || 'unknown',
5599
+ },
5600
+ });
5601
+ const moduleInitStart = performance.now();
5602
+ const instance = await module.initialize({
5603
+ ref,
5604
+ config: config[key],
5605
+ requireInstance,
5606
+ hasModule,
5607
+ });
5608
+ // Warn when providers deviate from the expected base class — these modules
5609
+ // may lack version tracking and standard provider interfaces.
5610
+ if (!(instance instanceof BaseModuleProvider)) {
5611
+ registerEvent({
5612
+ level: ModuleEventLevel.Warning,
5613
+ name: ModuleConfiguratorEventName.ProviderNotBaseModuleProvider,
5614
+ message: `Provider for module ${module.name} does not extend BaseModuleProvider`,
5615
+ properties: {
5616
+ moduleName: module.name,
5617
+ moduleVersion: module.version?.toString() || 'unknown',
5618
+ },
5619
+ });
5620
+ }
5621
+ // Providers should expose a version string for diagnostics and compatibility checks.
5622
+ // Warn when absent so module authors catch missing version early rather than at runtime.
5623
+ const maybeVersioned = instance;
5624
+ if (!maybeVersioned.version) {
5625
+ registerEvent({
5626
+ level: ModuleEventLevel.Warning,
5627
+ name: ModuleConfiguratorEventName.ProviderVersionWarning,
5628
+ message: `Provider for module ${module.name} does not expose version`,
5629
+ properties: {
5630
+ moduleName: module.name,
5631
+ moduleVersion: module.version?.toString() || 'unknown',
5632
+ },
5633
+ });
5634
+ }
5635
+ const moduleInitTime = Math.round(performance.now() - moduleInitStart);
5636
+ registerEvent({
5637
+ level: ModuleEventLevel.Debug,
5638
+ name: ModuleConfiguratorEventName.ModuleInitialized,
5639
+ message: `Module ${module.name} initialized in ${moduleInitTime}ms`,
5640
+ properties: {
5641
+ moduleName: module.name,
5642
+ moduleVersion: module.version?.toString() || 'unknown',
5643
+ providerName: typeof instance,
5644
+ providerVersion: maybeVersioned.version?.toString() || 'unknown',
5645
+ moduleInitTime,
5646
+ },
5647
+ metric: moduleInitTime,
5648
+ });
5649
+ return [key, instance];
5650
+ }
5651
+ /**
5652
+ * Creates a `requireInstance` resolver for use during module initialization.
5653
+ *
5654
+ * `requireInstance` is passed into each module's `initialize` call so it can
5655
+ * declare dependencies on other modules without knowing whether those modules
5656
+ * have already finished initializing. The resolver waits up to `wait` seconds
5657
+ * for the target module to appear in the shared `instance$` subject.
5658
+ *
5659
+ * @param moduleNames - Names of all modules registered in this initialization run.
5660
+ * @param instance$ - Shared subject accumulating initialized module instances.
5661
+ * @param registerEvent - Function to emit lifecycle events.
5662
+ * @returns A `requireInstance` function matching the shape expected by `ModuleInitializerArgs`.
5663
+ * @internal
5664
+ */
5665
+ function createRequireInstance(moduleNames, instance$, registerEvent) {
5666
+ // The implementation signature is concrete (name: string) but the public contract
5667
+ // must be the generic shape expected by ModuleInitializerArgs. Module names are
5668
+ // always strings at runtime — the keyof-derived `string | number` constraint comes
5669
+ // from TypeScript's keyof semantics, not actual usage.
5670
+ return function requireInstance(name, wait = 60) {
5671
+ // Fail fast if the caller requests a module that was never registered —
5672
+ // this almost always indicates a misconfiguration rather than a timing issue.
5673
+ if (!moduleNames.includes(name)) {
5674
+ const error = new Error(`Cannot require [${String(name)}] since module is not defined!`);
5675
+ error.name = 'ModuleNotDefinedError';
5676
+ registerEvent({
5677
+ level: ModuleEventLevel.Error,
5678
+ name: ModuleConfiguratorEventName.RequireInstanceModuleNotDefined,
5679
+ message: error.message,
5680
+ properties: { moduleName: String(name), wait },
5681
+ error,
5682
+ });
5683
+ throw error;
5684
+ }
5685
+ // Short-circuit: module is already in the accumulated instance object
5686
+ if (instance$.value[name]) {
5687
+ registerEvent({
5688
+ level: ModuleEventLevel.Debug,
5689
+ name: ModuleConfiguratorEventName.RequireInstanceModuleAlreadyInitialized,
5690
+ message: `Module [${String(name)}] is already initialized, skipping queue`,
5691
+ properties: { moduleName: String(name), wait },
5692
+ });
5693
+ return Promise.resolve(instance$.value[name]);
5694
+ }
5695
+ const requireStart = performance.now();
5696
+ registerEvent({
5697
+ level: ModuleEventLevel.Debug,
5698
+ name: ModuleConfiguratorEventName.RequireInstanceAwaitingModule,
5699
+ message: `Awaiting module [${String(name)}] initialization, timeout ${wait}s`,
5700
+ properties: { moduleName: String(name), wait },
5701
+ });
5702
+ // Wait for the module to appear in the shared instance subject, up to `wait` seconds.
5703
+ return firstValueFrom(instance$.pipe(
5704
+ // Ignore emissions until the requested module has been added to the instance map.
5705
+ filter((x) => !!x[name]),
5706
+ // Resolve the dependency promise with the provider instance, not the full module map.
5707
+ map$1((x) => x[name]),
5708
+ // Convert unresolved dependencies into a typed timeout error with lifecycle diagnostics.
5709
+ timeout({
5710
+ // requireInstance accepts seconds; RxJS timeout expects milliseconds.
5711
+ each: wait * 1000,
5712
+ with: () => throwError(() => {
5713
+ const error = new RequiredModuleTimeoutError();
5714
+ registerEvent({
5715
+ level: ModuleEventLevel.Error,
5716
+ name: ModuleConfiguratorEventName.RequireInstanceTimeout,
5717
+ message: `Module [${String(name)}] initialization timed out after ${wait}s`,
5718
+ properties: { moduleName: String(name), wait },
5719
+ error,
5720
+ });
5721
+ return error;
5722
+ }),
5723
+ }),
5724
+ // Emit timing diagnostics only after the dependency has actually resolved.
5725
+ tap(() => {
5726
+ const requireTime = Math.round(performance.now() - requireStart);
5727
+ registerEvent({
5728
+ level: ModuleEventLevel.Debug,
5729
+ name: ModuleConfiguratorEventName.RequireInstanceModuleResolved,
5730
+ message: `Module [${String(name)}] required in ${requireTime}ms`,
5731
+ properties: { moduleName: String(name), wait, requireTime },
5732
+ metric: requireTime,
5733
+ });
5734
+ })));
5735
+ };
5736
+ }
5737
+ /**
5738
+ * Runs the initialize lifecycle phase for all registered modules.
5739
+ *
5740
+ * Initializes all modules **concurrently** using `mergeMap`. Cross-module
5741
+ * dependency ordering is handled lazily through `requireInstance`, which
5742
+ * waits for a peer module's `initialize` call to complete before resolving.
5743
+ *
5744
+ * Each initialized provider is accumulated into a shared `BehaviorSubject` so
5745
+ * that `requireInstance` callers see updates as soon as a dependency is ready.
5746
+ *
5747
+ * @param ctx - The initialize phase context.
5748
+ * @param config - The merged module config map produced by the configure phase.
5749
+ * @param ref - Optional reference forwarded to each module's `initialize` call.
5750
+ * @returns A promise resolving to the sealed map of initialized module providers.
5751
+ * @throws {Error} When a module's `initialize` method is missing.
5752
+ * @throws {RequiredModuleTimeoutError} When a required dependency does not
5753
+ * initialize within its timeout window.
5754
+ */
5755
+ async function runInitializePhase(ctx, config, ref) {
5756
+ const { modules, registerEvent } = ctx;
5757
+ // Fast-path: no modules registered — return a sealed empty instance immediately
5758
+ // to avoid a subscribe/lastValueFrom race on an already-completed observable.
5759
+ if (modules.length === 0) {
5760
+ return Object.seal({});
5761
+ }
5762
+ const moduleNames = modules.map((m) => m.name);
5763
+ // Accumulates initialized module providers; BehaviorSubject lets requireInstance
5764
+ // reactively wait for a dependency to appear without polling.
5765
+ const instance$ = new BehaviorSubject({});
5766
+ const hasModule = (name) => moduleNames.includes(name);
5767
+ const requireInstance = createRequireInstance(moduleNames, instance$, registerEvent);
5768
+ // Initialize all modules concurrently; modules that depend on peers will
5769
+ // suspend inside requireInstance until the dependency resolves.
5770
+ const init$ = from(modules).pipe(mergeMap((module) => initializeModule(module, { config, ref, requireInstance, hasModule, registerEvent })));
5771
+ const initStart = performance.now();
5772
+ // Accumulate module providers into the shared instance subject as each resolves.
5773
+ // Completing the subject signals that all modules are initialized.
5774
+ init$.subscribe({
5775
+ next: ([name, module]) => {
5776
+ instance$.next(Object.assign(instance$.value, { [name]: module }));
5777
+ },
5778
+ error: (err) => {
5779
+ registerEvent({
5780
+ level: ModuleEventLevel.Error,
5781
+ name: ModuleConfiguratorEventName.ModuleInitializeError,
5782
+ message: `Failed to initialize module ${err.name || 'unknown'}`,
5783
+ error: err,
5784
+ });
5785
+ instance$.error(err);
5786
+ },
5787
+ complete: () => {
5788
+ const loadTime = Math.round(performance.now() - initStart);
5789
+ registerEvent({
5790
+ level: ModuleEventLevel.Debug,
5791
+ name: ModuleConfiguratorEventName.ModuleInitializeComplete,
5792
+ message: `All modules initialized in ${loadTime}ms`,
5793
+ properties: {
5794
+ modules: Object.keys(instance$.value).join(', '),
5795
+ loadTime,
5796
+ },
5797
+ metric: loadTime,
5798
+ });
5799
+ instance$.complete();
5800
+ },
5801
+ });
5802
+ const instanceInitStart = performance.now();
5803
+ const instance = await lastValueFrom(instance$);
5804
+ const initTime = Math.round(performance.now() - instanceInitStart);
5805
+ registerEvent({
5806
+ level: ModuleEventLevel.Debug,
5807
+ name: ModuleConfiguratorEventName.InitializeComplete,
5808
+ message: `Modules instance created in ${initTime}ms`,
5809
+ properties: {
5810
+ modules: Object.keys(instance).join(', '),
5811
+ initTime,
5812
+ },
5813
+ metric: initTime,
5814
+ });
5815
+ Object.seal(instance);
5816
+ return instance;
5817
+ }
5330
5818
 
5819
+ // biome-ignore-all lint/suspicious/noExplicitAny: internal type-erased dispatch — the post-initialize phase forwards opaque instances without inspecting their concrete shapes
5331
5820
  /* eslint-disable @typescript-eslint/no-explicit-any */
5332
5821
  /**
5333
- * Error thrown when a required module fails to initialize within the specified timeout period.
5822
+ * Runs the post-initialize lifecycle phase for all registered modules.
5823
+ *
5824
+ * Executes two sub-steps in order:
5825
+ * 1. Calls each module's `postInitialize` hook (if defined) concurrently.
5826
+ * Individual failures are caught and emitted as Warning events so one
5827
+ * failing module cannot block others.
5828
+ * 2. Runs all registered `afterInit` callbacks concurrently via `Promise.allSettled`.
5829
+ *
5830
+ * @param ctx - The post-initialize phase context.
5831
+ * @param instance - The sealed module instance map produced by the initialize phase.
5832
+ * @param ref - Optional reference forwarded to each module's `postInitialize` call.
5833
+ * @returns A promise resolving when all post-initialize hooks and callbacks have settled.
5834
+ */
5835
+ async function runPostInitializePhase(ctx, instance, ref) {
5836
+ const { modules, afterInit, registerEvent } = ctx;
5837
+ registerEvent({
5838
+ level: ModuleEventLevel.Debug,
5839
+ name: ModuleConfiguratorEventName.ConfiguratorPostInitializeStart,
5840
+ message: `Post-initializing all modules [${Object.keys(instance).length}]`,
5841
+ properties: { modules: Object.keys(instance).join(', ') },
5842
+ });
5843
+ // Run postInitialize hooks for modules that declare them. Failures are caught
5844
+ // per-module via catchError so one failure does not abort the others.
5845
+ const postInitialize$ = from(modules).pipe(filter((module) => !!module.postInitialize), tap((module) => {
5846
+ registerEvent({
5847
+ level: ModuleEventLevel.Debug,
5848
+ name: ModuleConfiguratorEventName.ModulePostInitializeStart,
5849
+ message: `Module ${module.name} is being post-initialized`,
5850
+ properties: {
5851
+ moduleName: module.name,
5852
+ moduleVersion: module.version?.toString() || 'unknown',
5853
+ },
5854
+ });
5855
+ }), mergeMap((module) => {
5856
+ const postInitStart = performance.now();
5857
+ return from(module.postInitialize({
5858
+ ref,
5859
+ modules: instance,
5860
+ instance: instance[module.name],
5861
+ })).pipe(tap(() => {
5862
+ const postInitTime = Math.round(performance.now() - postInitStart);
5863
+ registerEvent({
5864
+ level: ModuleEventLevel.Debug,
5865
+ name: ModuleConfiguratorEventName.ModulePostInitializeComplete,
5866
+ message: `Module ${module.name} has been post-initialized in ${postInitTime}ms`,
5867
+ metric: postInitTime,
5868
+ properties: {
5869
+ moduleName: module.name,
5870
+ moduleVersion: module.version?.toString() || 'unknown',
5871
+ postInitTime,
5872
+ },
5873
+ });
5874
+ }), defaultIfEmpty(null), catchError((err) => {
5875
+ registerEvent({
5876
+ level: ModuleEventLevel.Warning,
5877
+ name: ModuleConfiguratorEventName.ModulePostInitializeError,
5878
+ message: `Module ${module.name} post-initialize failed`,
5879
+ properties: {
5880
+ moduleName: module.name,
5881
+ moduleVersion: module.version?.toString() || 'unknown',
5882
+ },
5883
+ error: err,
5884
+ });
5885
+ // Swallow module-level errors — a failing postInitialize should not
5886
+ // prevent other modules from completing their post-initialize work.
5887
+ return EMPTY;
5888
+ }));
5889
+ }), defaultIfEmpty(null));
5890
+ const postInitStart = performance.now();
5891
+ await lastValueFrom(postInitialize$);
5892
+ const postInitTime = Math.round(performance.now() - postInitStart);
5893
+ registerEvent({
5894
+ level: ModuleEventLevel.Debug,
5895
+ name: ModuleConfiguratorEventName.PostInitializeComplete,
5896
+ message: `Post-initialization of all modules completed in ${postInitTime}ms`,
5897
+ properties: { modules: Object.keys(instance).join(', '), postInitTime },
5898
+ metric: postInitTime,
5899
+ });
5900
+ if (!afterInit.length) {
5901
+ registerEvent({
5902
+ level: ModuleEventLevel.Debug,
5903
+ name: ModuleConfiguratorEventName.PostInitializeCompleteNoHooks,
5904
+ message: 'Post-initialization complete',
5905
+ properties: { modules: Object.keys(instance).join(', '), postInitCompleteTime: postInitTime },
5906
+ });
5907
+ return;
5908
+ }
5909
+ // Run all registered afterInit callbacks. These were added either by
5910
+ // addConfig's afterInit or via onInitialized on the configurator.
5911
+ try {
5912
+ registerEvent({
5913
+ level: ModuleEventLevel.Debug,
5914
+ name: ModuleConfiguratorEventName.PostInitializeHooks,
5915
+ message: `Executing post-initialize hooks [${afterInit.length}]`,
5916
+ properties: { hooks: afterInit.map((x) => x.name || 'anonymous').join(', ') },
5917
+ });
5918
+ const afterInitStart = performance.now();
5919
+ await Promise.allSettled(afterInit.map((x) => Promise.resolve(x(instance))));
5920
+ const afterInitTime = Math.round(performance.now() - afterInitStart);
5921
+ registerEvent({
5922
+ level: ModuleEventLevel.Debug,
5923
+ name: ModuleConfiguratorEventName.PostInitializeHooksComplete,
5924
+ message: `Post-initialize hooks completed in ${afterInitTime}ms`,
5925
+ properties: {
5926
+ hooks: afterInit.map((x) => x.name || 'anonymous').join(', '),
5927
+ afterInitTime,
5928
+ },
5929
+ metric: afterInitTime,
5930
+ });
5931
+ }
5932
+ catch (err) {
5933
+ registerEvent({
5934
+ level: ModuleEventLevel.Warning,
5935
+ name: ModuleConfiguratorEventName.PostInitializeHooksError,
5936
+ message: 'Post-initialize hooks failed',
5937
+ properties: { hooks: afterInit.map((x) => x.name || 'anonymous').join(', ') },
5938
+ error: err,
5939
+ });
5940
+ }
5941
+ const postInitCompleteTime = Math.round(performance.now() - postInitStart);
5942
+ registerEvent({
5943
+ level: ModuleEventLevel.Debug,
5944
+ name: ModuleConfiguratorEventName.PostInitializeComplete,
5945
+ message: 'Post-initialization complete',
5946
+ properties: { modules: Object.keys(instance).join(', '), postInitCompleteTime },
5947
+ });
5948
+ }
5949
+
5950
+ // biome-ignore-all lint/suspicious/noExplicitAny: internal type-erased dispatch — plugins are registered with concrete module maps but stored erased by the orchestrator
5951
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5952
+ /**
5953
+ * Checks whether a plugin return value should be treated as dispose-time cleanup.
5334
5954
  *
5335
- * This error indicates that a module dependency was not available when expected,
5336
- * typically due to initialization delays or circular dependencies.
5955
+ * Plugins may return either a plain callback or an object with a `dispose` method.
5956
+ * Any other value is ignored so plugin authors can return `undefined` when no
5957
+ * cleanup is needed.
5958
+ *
5959
+ * @param value - Value returned by a registered plugin callback.
5960
+ * @returns True when the value is a valid plugin teardown registration.
5337
5961
  */
5338
- class RequiredModuleTimeoutError extends Error {
5339
- constructor() {
5340
- super('Module initialization timed out');
5341
- this.name = 'RequiredModuleTimeoutError';
5962
+ function isPluginTeardown(value) {
5963
+ return (typeof value === 'function' ||
5964
+ (typeof value === 'object' &&
5965
+ value !== null &&
5966
+ 'dispose' in value &&
5967
+ typeof value.dispose === 'function'));
5968
+ }
5969
+ /**
5970
+ * Runs configurator plugins after modules are ready.
5971
+ *
5972
+ * The plugin phase is the final initialization step before `initialize()`
5973
+ * resolves. Each plugin receives the sealed module instance map and optional
5974
+ * initialization reference, which makes this phase suitable for application
5975
+ * side effects such as telemetry bridges, global event listeners, and runtime
5976
+ * subscriptions that require multiple initialized module providers.
5977
+ *
5978
+ * Plugin callbacks run concurrently. Failures are isolated and emitted as
5979
+ * warning events so one failing side effect cannot block application rendering.
5980
+ * Returned teardown callbacks are stored for the dispose phase and are invoked
5981
+ * before module `dispose` hooks.
5982
+ *
5983
+ * @param ctx - The plugin phase context.
5984
+ * @param modules - The initialized module instance map.
5985
+ * @param ref - Optional reference forwarded from module initialization.
5986
+ * @returns A promise resolving when all plugin callbacks have settled.
5987
+ */
5988
+ async function runPluginPhase(ctx, modules, ref) {
5989
+ const { plugins, teardowns, registerEvent } = ctx;
5990
+ if (!plugins.length)
5991
+ return;
5992
+ registerEvent({
5993
+ level: ModuleEventLevel.Debug,
5994
+ name: ModuleConfiguratorEventName.PluginsRegister,
5995
+ message: `Registering plugins [${plugins.length}]`,
5996
+ properties: { count: plugins.length },
5997
+ });
5998
+ const pluginRegistrations = await Promise.all(plugins.map(async (plugin) => {
5999
+ const pluginStart = performance.now();
6000
+ const name = plugin.name || 'anonymous';
6001
+ try {
6002
+ const teardown = await plugin({ modules, ref });
6003
+ const pluginTime = Math.round(performance.now() - pluginStart);
6004
+ registerEvent({
6005
+ level: ModuleEventLevel.Debug,
6006
+ name: ModuleConfiguratorEventName.PluginRegistered,
6007
+ message: `Plugin ${name} registered in ${pluginTime}ms`,
6008
+ properties: { name, pluginTime },
6009
+ metric: pluginTime,
6010
+ });
6011
+ return isPluginTeardown(teardown) ? teardown : undefined;
6012
+ }
6013
+ catch (err) {
6014
+ registerEvent({
6015
+ level: ModuleEventLevel.Warning,
6016
+ name: ModuleConfiguratorEventName.PluginRegisterError,
6017
+ message: `Plugin ${name} registration failed`,
6018
+ properties: { name },
6019
+ error: err,
6020
+ });
6021
+ return undefined;
6022
+ }
6023
+ }));
6024
+ for (const teardown of pluginRegistrations) {
6025
+ if (teardown) {
6026
+ teardowns.push(teardown);
6027
+ }
6028
+ }
6029
+ registerEvent({
6030
+ level: ModuleEventLevel.Debug,
6031
+ name: ModuleConfiguratorEventName.PluginsRegistered,
6032
+ message: 'Plugin registration complete',
6033
+ properties: { count: plugins.length, teardowns: teardowns.length },
6034
+ });
6035
+ }
6036
+
6037
+ function getPluginTeardownName(teardown) {
6038
+ return typeof teardown === 'function' ? teardown.name || 'anonymous' : 'dispose';
6039
+ }
6040
+ async function runPluginTeardown(teardown) {
6041
+ if (typeof teardown === 'function') {
6042
+ await teardown();
6043
+ return;
5342
6044
  }
6045
+ await teardown.dispose();
5343
6046
  }
6047
+ /**
6048
+ * Runs the dispose lifecycle phase for all registered modules.
6049
+ *
6050
+ * Calls each module's `dispose` hook (if defined) concurrently via
6051
+ * `Promise.allSettled` so one failing module cannot block others from
6052
+ * being torn down. After all hooks settle, the event stream is completed.
6053
+ *
6054
+ * @param ctx - The dispose phase context.
6055
+ * @param instance - The initialized module instance map to tear down.
6056
+ * @param ref - Optional reference forwarded to each module's `dispose` call.
6057
+ * @returns A promise resolving when all module dispose hooks have settled and
6058
+ * the event stream has been completed.
6059
+ */
6060
+ async function runDisposePhase(ctx, instance, ref) {
6061
+ const { modules, registerEvent, event$, pluginTeardowns = [] } = ctx;
6062
+ registerEvent({
6063
+ level: ModuleEventLevel.Debug,
6064
+ name: ModuleConfiguratorEventName.Dispose,
6065
+ message: 'Disposing modules instance',
6066
+ properties: { modules: Object.keys(instance).join(', ') },
6067
+ });
6068
+ if (pluginTeardowns.length) {
6069
+ registerEvent({
6070
+ level: ModuleEventLevel.Debug,
6071
+ name: ModuleConfiguratorEventName.PluginsDisposing,
6072
+ message: `Disposing plugins [${pluginTeardowns.length}]`,
6073
+ properties: { count: pluginTeardowns.length },
6074
+ });
6075
+ // Tear down plugins before module providers so side effects can still access
6076
+ // live providers while unsubscribing. LIFO mirrors common subscription stacks.
6077
+ for (const teardown of pluginTeardowns.splice(0).reverse()) {
6078
+ const name = getPluginTeardownName(teardown);
6079
+ try {
6080
+ await runPluginTeardown(teardown);
6081
+ registerEvent({
6082
+ level: ModuleEventLevel.Debug,
6083
+ name: ModuleConfiguratorEventName.PluginDisposed,
6084
+ message: `Plugin ${name} disposed successfully`,
6085
+ properties: { name },
6086
+ });
6087
+ }
6088
+ catch (err) {
6089
+ registerEvent({
6090
+ level: ModuleEventLevel.Warning,
6091
+ name: ModuleConfiguratorEventName.PluginDisposeError,
6092
+ message: `Plugin ${name} dispose failed`,
6093
+ properties: { name },
6094
+ error: err,
6095
+ });
6096
+ }
6097
+ }
6098
+ }
6099
+ registerEvent({
6100
+ level: ModuleEventLevel.Debug,
6101
+ name: ModuleConfiguratorEventName.ModulesDispose,
6102
+ message: 'Disposing modules',
6103
+ properties: { count: modules.length },
6104
+ });
6105
+ // Dispose all modules concurrently; failures are isolated per module so
6106
+ // one bad teardown cannot leave other modules in an inconsistent state.
6107
+ await Promise.allSettled(modules
6108
+ .filter((module) => !!module.dispose)
6109
+ .map(async (module) => {
6110
+ if (!module.dispose)
6111
+ return;
6112
+ try {
6113
+ await module.dispose({
6114
+ ref,
6115
+ modules: instance,
6116
+ instance: instance[module.name],
6117
+ });
6118
+ registerEvent({
6119
+ level: ModuleEventLevel.Debug,
6120
+ name: ModuleConfiguratorEventName.ModuleDisposed,
6121
+ message: `Module ${module.name} disposed successfully`,
6122
+ properties: {
6123
+ moduleName: module.name,
6124
+ moduleVersion: module.version?.toString() || 'unknown',
6125
+ },
6126
+ });
6127
+ }
6128
+ catch (err) {
6129
+ registerEvent({
6130
+ level: ModuleEventLevel.Warning,
6131
+ name: ModuleConfiguratorEventName.ModuleDisposeError,
6132
+ message: `Module ${module.name} dispose failed`,
6133
+ properties: {
6134
+ moduleName: module.name,
6135
+ moduleVersion: module.version?.toString() || 'unknown',
6136
+ },
6137
+ error: err,
6138
+ });
6139
+ }
6140
+ }));
6141
+ registerEvent({
6142
+ level: ModuleEventLevel.Debug,
6143
+ name: ModuleConfiguratorEventName.ModulesDisposed,
6144
+ message: 'Module dispose complete',
6145
+ properties: { count: modules.length },
6146
+ });
6147
+ // Complete the event stream last so all dispose events are captured before
6148
+ // any subscriber teardown triggered by completion.
6149
+ event$.complete();
6150
+ }
6151
+
6152
+ // Generated by genversion.
6153
+ const version$8 = '6.1.0';
6154
+
6155
+ // biome-ignore-all lint/suspicious/noExplicitAny: internal type-erased dispatch arrays — callbacks are registered with concrete module types but stored erased; the orchestrator never inspects these shapes itself
6156
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5344
6157
  /**
5345
6158
  * Core orchestrator that drives the module lifecycle in Fusion Framework.
5346
6159
  *
5347
- * `ModulesConfigurator` manages the full configureinitialize dispose pipeline
5348
- * for a set of modules. Consumers register modules via {@link addConfig} or
5349
- * {@link configure}, then call {@link initialize} to produce a sealed
5350
- * {@link ModulesInstance} whose properties are the initialized module providers.
6160
+ * `ModulesConfigurator` manages the full **configure post-configure → initialize
6161
+ * post-initialize → plugin → dispose** pipeline for a set of modules. Consumers
6162
+ * register modules via {@link addConfig} or {@link configure}, then call
6163
+ * {@link initialize} to produce a sealed {@link ModulesInstance} whose properties
6164
+ * are the initialized module providers.
6165
+ *
6166
+ * ### Lifecycle phases (in execution order)
6167
+ *
6168
+ * | # | Phase | Entry point | Description |
6169
+ * |---|-------|-------------|-------------|
6170
+ * | 1 | **Configure** | `_configure` | Each module's `configure()` factory creates a config builder; registered callbacks mutate it. |
6171
+ * | 2 | **Post-configure** | `_postConfigure` (inside `_configure`) | `postConfigure()` hooks and `onConfigured` callbacks run. |
6172
+ * | 3 | **Initialize** | `_initialize` | Modules are initialized concurrently; cross-module dependencies are resolved through `requireInstance`. |
6173
+ * | 4 | **Post-initialize** | `_postInitialize` | `postInitialize()` hooks and `onInitialized` callbacks run. |
6174
+ * | 5 | **Plugin** | `_registerPlugins` (inside `initialize`) | Registered application plugins connect side effects after modules are ready. |
6175
+ * | 6 | **Dispose** | `dispose` | Plugin teardowns and module `dispose()` hooks run; the event stream is completed. |
5351
6176
  *
5352
- * The lifecycle phases executed during {@link initialize} are:
6177
+ * ### Registering phase callbacks
5353
6178
  *
5354
- * 1. **Configure** each module’s `configure()` factory creates a config builder;
5355
- * registered callbacks mutate it; `postConfigure()` hooks run.
5356
- * 2. **Initialize** modules are initialized concurrently via `initialize()`;
5357
- * cross-module dependencies are resolved through `requireInstance()`.
5358
- * 3. **Post-initialize** – `postInitialize()` hooks and `onInitialized` callbacks run.
6179
+ * - **Per-module callbacks**: use `addConfig({ module, configure, afterConfig, afterInit })`.
6180
+ * - **Global post-configure**: use `onConfigured(cb)`.
6181
+ * - **Global post-initialize**: use `onInitialized(cb)`.
6182
+ * - **Plugins**: use `registerPlugin(cb)` to connect side effects before render.
5359
6183
  *
5360
6184
  * All lifecycle transitions emit {@link ModuleEvent} entries on the {@link event$}
5361
6185
  * observable for telemetry and debugging.
@@ -5376,57 +6200,97 @@ class RequiredModuleTimeoutError extends Error {
5376
6200
  */
5377
6201
  class ModulesConfigurator {
5378
6202
  /**
5379
- * The class name used for event naming. This static property ensures
5380
- * the name is preserved through compilation and minification.
6203
+ * Class name used as a namespace prefix for all emitted lifecycle events.
6204
+ * Preserved as a static string so minification cannot change it at runtime.
5381
6205
  */
5382
6206
  static className = 'ModulesConfigurator';
5383
6207
  get version() {
5384
6208
  return version$8;
5385
6209
  }
5386
- // Buffer up to 100 events to prevent memory leaks while ensuring telemetry can capture
5387
- // module events during configuration. Telemetry attaches via mapConfiguratorEvents and
5388
- // needs to replay events that occurred before it was ready.
5389
- // Memory usage: ~24KB for 100 events at ~240 bytes each.
6210
+ // Buffer up to 100 events to prevent memory leaks while ensuring telemetry
6211
+ // can capture events that fire before a telemetry subscriber attaches.
6212
+ // mapConfiguratorEvents relies on replay to receive events emitted during
6213
+ // configuration before telemetry is wired up.
6214
+ // Memory bound: ~24 KB at ~240 bytes/event × 100 events.
5390
6215
  #event$ = new ReplaySubject(100);
5391
6216
  get event$() {
5392
6217
  return this.#event$.asObservable();
5393
6218
  }
5394
6219
  /**
5395
- * Array of configuration callbacks.
6220
+ * Registered configure-phase callbacks.
6221
+ * Each entry is added by {@link addConfig} when a `configure` callback is provided.
5396
6222
  * @protected
5397
- * @sealed
5398
6223
  */
5399
6224
  _configs = [];
5400
6225
  /**
5401
- * Array of callbacks to be executed after configuration.
6226
+ * Registered post-configure callbacks.
6227
+ * Populated by {@link onConfigured} and by `afterConfig` entries in {@link addConfig}.
6228
+ * Also exposed on the config object as `config.onAfterConfiguration` so modules
6229
+ * can register additional hooks during their own configure factory.
6230
+ *
6231
+ * Typed as `any` because this is an internal dispatch array: callbacks are registered
6232
+ * with concrete module-specific types but stored erased — the orchestrator never
6233
+ * inspects the config shape itself, it only forwards it at call time.
6234
+ * @protected
5402
6235
  */
5403
6236
  _afterConfiguration = [];
5404
6237
  /**
5405
- * Array of callbacks to be executed after initialization.
6238
+ * Registered post-initialize callbacks.
6239
+ * Populated by {@link onInitialized} and by `afterInit` entries in {@link addConfig}.
6240
+ * Also exposed on the config object as `config.onAfterInit`.
6241
+ *
6242
+ * Typed as `any` for the same reason as {@link _afterConfiguration} — type-erased
6243
+ * internal dispatch; concrete instance types are known at registration but not stored.
6244
+ * @protected
5406
6245
  */
5407
6246
  _afterInit = [];
5408
6247
  /**
5409
- * Set of modules.
6248
+ * Registered plugin callbacks.
6249
+ *
6250
+ * Plugins run after all modules have initialized and before initialize resolves.
6251
+ * Typed as `any` because callbacks are registered with concrete module maps but
6252
+ * stored erased by the base orchestrator.
6253
+ * @protected
6254
+ */
6255
+ _plugins = [];
6256
+ /**
6257
+ * Teardown callbacks returned by registered plugins.
6258
+ *
6259
+ * Consumed during dispose and cleared after execution so repeated dispose calls
6260
+ * do not run plugin cleanup more than once.
6261
+ * @protected
6262
+ */
6263
+ _pluginTeardowns = [];
6264
+ /**
6265
+ * Set of all registered module descriptors.
6266
+ * Uses a `Set` for automatic deduplication — the same module registered twice
6267
+ * is treated as a single registration.
6268
+ * @protected
5410
6269
  */
5411
6270
  _modules;
5412
6271
  /**
5413
- * Constructs a new ModulesConfigurator instance.
5414
- * @param modules - Optional array of modules to initialize with.
6272
+ * Creates a new `ModulesConfigurator` with an optional initial set of modules.
6273
+ *
6274
+ * @param modules - Optional array of module descriptors to pre-register.
5415
6275
  */
5416
6276
  constructor(modules) {
5417
- // Use Set for efficient lookups and automatic deduplication of modules
5418
6277
  this._modules = new Set(modules);
5419
6278
  }
5420
6279
  /**
5421
- * Gets the array of modules.
5422
- * @returns Array of modules.
6280
+ * Returns all registered module descriptors as an ordered array.
6281
+ *
6282
+ * @returns Array of registered modules in insertion order.
5423
6283
  */
5424
6284
  get modules() {
5425
6285
  return [...this._modules];
5426
6286
  }
5427
6287
  /**
5428
- * Configures the modules with the provided configurators.
5429
- * @param configs - Array of module configurators.
6288
+ * Registers one or more module configurators.
6289
+ *
6290
+ * Convenience wrapper around {@link addConfig} for registering multiple
6291
+ * modules in a single call.
6292
+ *
6293
+ * @param configs - One or more module configurator descriptors.
5430
6294
  */
5431
6295
  configure(...configs) {
5432
6296
  for (const x of configs) {
@@ -5434,15 +6298,21 @@ class ModulesConfigurator {
5434
6298
  }
5435
6299
  }
5436
6300
  /**
5437
- * Adds a module configurator.
5438
- * @param config - Module configurator.
6301
+ * Registers a single module configurator.
6302
+ *
6303
+ * Adds the module to the known module set and registers the optional
6304
+ * `configure`, `afterConfig`, and `afterInit` callbacks into their
6305
+ * respective lifecycle phase arrays.
6306
+ *
6307
+ * @param config - The module configurator descriptor to register.
6308
+ * @template T - The module type being registered.
5439
6309
  */
5440
6310
  addConfig(config) {
5441
6311
  const { module, afterConfig, afterInit, configure } = config;
5442
6312
  this._modules.add(module);
5443
6313
  this._registerEvent({
5444
6314
  level: ModuleEventLevel.Debug,
5445
- name: 'moduleConfigAdded',
6315
+ name: ModuleConfiguratorEventName.ModuleConfigAdded,
5446
6316
  message: `Module configurator added for ${module.name}`,
5447
6317
  properties: {
5448
6318
  moduleName: module.name,
@@ -5452,19 +6322,28 @@ class ModulesConfigurator {
5452
6322
  afterInit: !!afterInit,
5453
6323
  },
5454
6324
  });
5455
- configure && this._configs.push((config, ref) => configure(config[module.name], ref));
5456
- afterConfig && this._afterConfiguration.push((config) => afterConfig(config[module.name]));
5457
- afterInit && this._afterInit.push((instances) => afterInit(instances[module.name]));
6325
+ // Register each optional callback into its corresponding lifecycle phase array
6326
+ if (configure)
6327
+ this._configs.push((cfg, ref) => configure(cfg[module.name], ref));
6328
+ if (afterConfig)
6329
+ this._afterConfiguration.push((cfg) => afterConfig(cfg[module.name]));
6330
+ if (afterInit)
6331
+ this._afterInit.push((instances) => afterInit(instances[module.name]));
5458
6332
  }
5459
6333
  /**
5460
- * Registers a callback to be executed after configuration.
5461
- * @param cb - Callback function.
6334
+ * Registers a callback for the post-configure phase.
6335
+ *
6336
+ * The callback receives the merged module config map after all `configure`
6337
+ * callbacks have run and before module initialization begins.
6338
+ *
6339
+ * @param cb - Callback receiving the merged module config map.
6340
+ * @template T - Additional modules to include in the config type.
5462
6341
  */
5463
6342
  onConfigured(cb) {
5464
6343
  this._afterConfiguration.push(cb);
5465
6344
  this._registerEvent({
5466
6345
  level: ModuleEventLevel.Debug,
5467
- name: 'addOnConfigured',
6346
+ name: ModuleConfiguratorEventName.OnConfiguredAdded,
5468
6347
  message: 'Added onConfigured callback',
5469
6348
  properties: {
5470
6349
  count: this._afterConfiguration.length,
@@ -5473,14 +6352,19 @@ class ModulesConfigurator {
5473
6352
  });
5474
6353
  }
5475
6354
  /**
5476
- * Registers a callback to be executed after initialization.
5477
- * @param cb - Callback function.
6355
+ * Registers a callback for the post-initialize phase.
6356
+ *
6357
+ * The callback receives the sealed module instance after all modules have
6358
+ * been initialized and their `postInitialize` hooks have run.
6359
+ *
6360
+ * @param cb - Callback receiving the sealed module instance.
6361
+ * @template T - Additional modules to include in the instance type.
5478
6362
  */
5479
6363
  onInitialized(cb) {
5480
6364
  this._afterInit.push(cb);
5481
6365
  this._registerEvent({
5482
6366
  level: ModuleEventLevel.Debug,
5483
- name: 'addOnInitialized',
6367
+ name: ModuleConfiguratorEventName.OnInitializedAdded,
5484
6368
  message: 'Added onInitialized callback',
5485
6369
  properties: {
5486
6370
  count: this._afterInit.length,
@@ -5489,9 +6373,51 @@ class ModulesConfigurator {
5489
6373
  });
5490
6374
  }
5491
6375
  /**
5492
- * Initializes the modules with the provided reference.
5493
- * @param ref - Reference object.
5494
- * @returns Promise that resolves to the initialized module instance.
6376
+ * Registers a plugin that connects side effects after modules are initialized.
6377
+ *
6378
+ * The callback runs after `postInitialize` and `onInitialized` callbacks have
6379
+ * settled, but before {@link initialize} resolves. Return a teardown callback
6380
+ * to clean up subscriptions or listeners during {@link dispose}.
6381
+ *
6382
+ * @param cb - Plugin callback receiving the initialized module map and optional ref.
6383
+ * @template T - Additional modules to include in the plugin module map.
6384
+ * @example
6385
+ * ```typescript
6386
+ * function connectContextTelemetry(args: FrameworkPluginArgs<[EventModule, TelemetryModule]>) {
6387
+ * const teardown = args.modules.event.addEventListener('context:changed', (event) => {
6388
+ * args.modules.telemetry.track('context.changed', event.detail);
6389
+ * });
6390
+ *
6391
+ * return teardown;
6392
+ * }
6393
+ *
6394
+ * configurator.registerPlugin(connectContextTelemetry);
6395
+ * ```
6396
+ */
6397
+ registerPlugin(cb) {
6398
+ this._plugins.push(cb);
6399
+ this._registerEvent({
6400
+ level: ModuleEventLevel.Debug,
6401
+ name: ModuleConfiguratorEventName.PluginAdded,
6402
+ message: 'Added plugin callback',
6403
+ properties: {
6404
+ count: this._plugins.length,
6405
+ name: cb.name || 'anonymous',
6406
+ },
6407
+ });
6408
+ }
6409
+ /**
6410
+ * Runs the full configure → initialize pipeline and returns a sealed module instance.
6411
+ *
6412
+ * Execution order:
6413
+ * 1. {@link _configure} — configure phase (creates config, applies callbacks, post-configure hooks).
6414
+ * 2. {@link _initialize} — initialize phase (concurrent module init with `requireInstance`).
6415
+ * 3. {@link _postInitialize} — post-initialize phase (`postInitialize` hooks + `onInitialized` callbacks).
6416
+ * 4. {@link _registerPlugins} — plugin phase (`registerPlugin` callbacks connect side effects).
6417
+ *
6418
+ * @param ref - Optional reference forwarded to all module lifecycle hooks.
6419
+ * @returns A promise resolving to the sealed, initialized module instance.
6420
+ * @template T - Additional modules to merge into the instance type.
5495
6421
  */
5496
6422
  async initialize(ref) {
5497
6423
  const configStart = performance.now();
@@ -5499,7 +6425,7 @@ class ModulesConfigurator {
5499
6425
  const configLoadTime = Math.round(performance.now() - configStart);
5500
6426
  this._registerEvent({
5501
6427
  level: ModuleEventLevel.Debug,
5502
- name: 'initialize.configLoaded',
6428
+ name: ModuleConfiguratorEventName.InitializeConfigLoaded,
5503
6429
  message: `Modules configured in ${configLoadTime}ms`,
5504
6430
  properties: {
5505
6431
  modules: this.modules.map((m) => m.name).join(', '),
@@ -5513,7 +6439,7 @@ class ModulesConfigurator {
5513
6439
  const instanceLoadTime = Math.round(performance.now() - instanceStart);
5514
6440
  this._registerEvent({
5515
6441
  level: ModuleEventLevel.Debug,
5516
- name: 'initialize.instanceInitialized',
6442
+ name: ModuleConfiguratorEventName.InitializeInstanceInitialized,
5517
6443
  message: `Modules initialized in ${instanceLoadTime}ms`,
5518
6444
  properties: {
5519
6445
  modules: this.modules.map((m) => m.name).join(', '),
@@ -5525,7 +6451,7 @@ class ModulesConfigurator {
5525
6451
  const totalLoadTime = configLoadTime + instanceLoadTime;
5526
6452
  this._registerEvent({
5527
6453
  level: ModuleEventLevel.Information,
5528
- name: 'initialize',
6454
+ name: ModuleConfiguratorEventName.Initialize,
5529
6455
  message: `initialize in ${totalLoadTime}ms`,
5530
6456
  properties: {
5531
6457
  modules: this.modules.map((m) => m.name).join(', '),
@@ -5536,560 +6462,126 @@ class ModulesConfigurator {
5536
6462
  metric: totalLoadTime,
5537
6463
  });
5538
6464
  await this._postInitialize(instance, ref);
5539
- return Object.seal(Object.assign({}, instance, {
6465
+ const modules = Object.seal(Object.assign({}, instance, {
5540
6466
  dispose: () => this.dispose(instance),
5541
6467
  }));
6468
+ await this._registerPlugins(modules, ref);
6469
+ return modules;
5542
6470
  }
5543
6471
  /**
5544
- * Registers a module event by namespacing it with the configurator class name.
6472
+ * Namespaces and emits a lifecycle event into the internal event stream.
5545
6473
  *
5546
- * Event names are prefixed with the constructor name to create unique, namespaced
5547
- * event identifiers that prevent conflicts between different configurator instances.
5548
- * For example, "moduleConfigAdded" becomes "ModulesConfigurator::moduleConfigAdded".
6474
+ * The event name is prefixed with the configurator class name (e.g.
6475
+ * `"ModulesConfigurator::ModuleConfigurator.module.configAdded"`) to prevent
6476
+ * name collisions between nested configurators.
5549
6477
  *
5550
- * @param event - The module event to register
6478
+ * @param event - The lifecycle event to emit.
5551
6479
  * @protected
5552
6480
  */
5553
6481
  _registerEvent(event) {
5554
- // Split event name by '::' to handle already-namespaced events
6482
+ // Split on '::' to avoid double-prefixing already-namespaced event names
5555
6483
  const nameParts = event.name.split('::');
5556
6484
  this.#event$.next({
5557
6485
  ...event,
5558
- // Prefix the event name with the configurator class name
5559
6486
  name: `${this.constructor.className}::${nameParts[nameParts.length - 1]}`,
5560
6487
  });
5561
6488
  }
5562
6489
  /**
5563
- * Configures the modules with the provided reference.
5564
- * @param ref - Reference object.
5565
- * @returns Promise that resolves to the module configuration.
6490
+ * Runs the configure lifecycle phase.
6491
+ *
6492
+ * Delegates to {@link runConfigurePhase} which creates module config builders,
6493
+ * applies registered callbacks, and runs post-configure hooks.
6494
+ *
6495
+ * Override this method in a subclass to customize the configure phase.
6496
+ *
6497
+ * @param ref - Optional reference forwarded to module configure factories.
6498
+ * @returns A promise resolving to the merged module config map.
6499
+ * @protected
5566
6500
  */
5567
6501
  async _configure(ref) {
5568
- const config = await this._createConfig(ref);
5569
- await Promise.all(this._configs.map((x) => Promise.resolve(x(config, ref))));
5570
- await this._postConfigure(config);
5571
- return config;
6502
+ return runConfigurePhase({
6503
+ modules: this.modules,
6504
+ configs: this._configs,
6505
+ afterConfiguration: this._afterConfiguration,
6506
+ afterInit: this._afterInit,
6507
+ registerEvent: this._registerEvent.bind(this),
6508
+ }, ref);
5572
6509
  }
5573
6510
  /**
5574
- * Creates the module configuration with the provided reference.
5575
- * @param ref - Reference object.
5576
- * @returns Promise that resolves to the module configuration.
6511
+ * Runs the initialize lifecycle phase.
6512
+ *
6513
+ * Delegates to {@link runInitializePhase} which initializes all modules
6514
+ * concurrently and resolves cross-module dependencies through `requireInstance`.
6515
+ *
6516
+ * Override this method in a subclass to customize the initialize phase.
6517
+ *
6518
+ * @param config - The merged module config map from the configure phase.
6519
+ * @param ref - Optional reference forwarded to each module's `initialize` call.
6520
+ * @returns A promise resolving to the sealed map of initialized module providers.
6521
+ * @protected
5577
6522
  */
5578
- _createConfig(ref) {
5579
- const { modules, _afterConfiguration, _afterInit } = this;
5580
- const config$ = from(modules).pipe(
5581
- // TODO: Add proper error handling for individual module config creation failures
5582
- mergeMap(async (module) => {
5583
- const configStart = performance.now();
5584
- try {
5585
- const configurator = await module.configure?.(ref);
5586
- const configLoadTime = Math.round(performance.now() - configStart);
5587
- this._registerEvent({
5588
- level: ModuleEventLevel.Debug,
5589
- name: '_createConfig.configuratorCreated',
5590
- message: `Configurator created for ${module.name} in ${configLoadTime}ms`,
5591
- properties: {
5592
- moduleName: module.name,
5593
- moduleVersion: module.version?.toString() || 'unknown',
5594
- configLoadTime,
5595
- },
5596
- metric: configLoadTime,
5597
- });
5598
- return { [module.name]: configurator };
5599
- }
5600
- catch (err) {
5601
- this._registerEvent({
5602
- level: ModuleEventLevel.Error,
5603
- name: '_createConfig.configuratorFailed',
5604
- message: `Failed to create configurator for ${module.name}`,
5605
- properties: {
5606
- moduleName: module.name,
5607
- moduleVersion: module.version?.toString() || 'unknown',
5608
- },
5609
- metric: Math.round(performance.now() - configStart),
5610
- error: err,
5611
- });
5612
- throw err;
5613
- }
5614
- }), reduce((acc, module) => Object.assign(acc, module), {
5615
- onAfterConfiguration(cb) {
5616
- _afterConfiguration.push(cb);
5617
- },
5618
- onAfterInit(cb) {
5619
- _afterInit.push(cb);
5620
- },
5621
- }));
5622
- return lastValueFrom(config$);
6523
+ async _initialize(config, ref) {
6524
+ return runInitializePhase({
6525
+ modules: this.modules,
6526
+ registerEvent: this._registerEvent.bind(this),
6527
+ }, config, ref);
5623
6528
  }
5624
6529
  /**
5625
- * Executes post-configuration tasks.
5626
- * @param config - Module configuration.
5627
- * @returns Promise that resolves when post-configuration tasks are complete.
6530
+ * Runs the post-initialize lifecycle phase.
6531
+ *
6532
+ * Delegates to {@link runPostInitializePhase} which calls each module's
6533
+ * `postInitialize` hook and then runs all `onInitialized` callbacks.
6534
+ *
6535
+ * Override this method in a subclass to customize the post-initialize phase.
6536
+ *
6537
+ * @param instance - The sealed module instance from the initialize phase.
6538
+ * @param ref - Optional reference forwarded to each module's `postInitialize` call.
6539
+ * @protected
5628
6540
  */
5629
- async _postConfigure(config) {
5630
- const { modules, _afterConfiguration: afterConfiguration } = this;
5631
- await Promise.allSettled(modules
5632
- .filter((module) => !!module.postConfigure)
5633
- .map(async (module) => {
5634
- try {
5635
- const postConfigStart = performance.now();
5636
- await module.postConfigure?.(config);
5637
- this._registerEvent({
5638
- level: ModuleEventLevel.Debug,
5639
- name: '_postConfigure.modulePostConfigured',
5640
- message: `Module ${module.name} post-configured successfully`,
5641
- properties: {
5642
- moduleName: module.name,
5643
- moduleVersion: module.version?.toString() || 'unknown',
5644
- postConfigTime: Math.round(performance.now() - postConfigStart),
5645
- },
5646
- });
5647
- }
5648
- catch (err) {
5649
- this._registerEvent({
5650
- level: ModuleEventLevel.Warning,
5651
- name: '_postConfigure.modulePostConfigureError',
5652
- message: `Module ${module.name} post-configure failed`,
5653
- properties: {
5654
- moduleName: module.name,
5655
- moduleVersion: module.version?.toString() || 'unknown',
5656
- },
5657
- error: err,
5658
- });
5659
- }
5660
- }));
5661
- /** call all added post config hooks */
5662
- if (afterConfiguration.length) {
5663
- try {
5664
- this._registerEvent({
5665
- level: ModuleEventLevel.Debug,
5666
- name: '_postConfigure.hooks',
5667
- message: `Post configure hooks [${afterConfiguration.length}] called`,
5668
- });
5669
- const postConfigHooksStart = performance.now();
5670
- await Promise.allSettled(afterConfiguration.map((x) => Promise.resolve(x(config))));
5671
- const postConfigHooksTime = Math.round(performance.now() - postConfigHooksStart);
5672
- this._registerEvent({
5673
- level: ModuleEventLevel.Debug,
5674
- name: '_postConfigure.hooksComplete',
5675
- message: 'Post configure hooks complete',
5676
- properties: {
5677
- count: afterConfiguration.length,
5678
- postConfigHooksTime,
5679
- },
5680
- metric: postConfigHooksTime,
5681
- });
5682
- }
5683
- catch (err) {
5684
- this._registerEvent({
5685
- level: ModuleEventLevel.Warning,
5686
- name: '_postConfigure.hooksError',
5687
- message: 'Post configure hook failed',
5688
- error: err,
5689
- });
5690
- }
5691
- }
6541
+ async _postInitialize(instance, ref) {
6542
+ return runPostInitializePhase({
6543
+ modules: this.modules,
6544
+ afterInit: this._afterInit,
6545
+ registerEvent: this._registerEvent.bind(this),
6546
+ }, instance, ref);
5692
6547
  }
5693
6548
  /**
5694
- * Initializes the modules with the provided configuration and reference.
5695
- * @param config - Module configuration.
5696
- * @param ref - Reference object.
5697
- * @returns Promise that resolves to the initialized module instance.
6549
+ * Runs the plugin lifecycle phase.
6550
+ *
6551
+ * Delegates to {@link runPluginPhase} which calls each registered plugin and
6552
+ * stores returned teardown callbacks for dispose.
6553
+ *
6554
+ * Override this method in a subclass to customize plugin registration.
6555
+ *
6556
+ * @param instance - The sealed module instance from the initialize phase.
6557
+ * @param ref - Optional reference forwarded to each plugin callback.
6558
+ * @protected
5698
6559
  */
5699
- async _initialize(config, ref) {
5700
- const moduleNames = this.modules.map((m) => m.name);
5701
- const instance$ = new BehaviorSubject({});
5702
- /** Method to check if a module is defined */
5703
- const hasModule = (name) => moduleNames.includes(name);
5704
- /**
5705
- * Requires and returns an initialized module instance by its name.
5706
- *
5707
- * If the requested module is already initialized, returns it immediately as a resolved Promise.
5708
- * If the module is not yet initialized, waits for its initialization and resolves with the instance,
5709
- * or rejects with a timeout error if the module is not initialized within the specified time.
5710
- *
5711
- * Throws an error immediately if the requested module name is not defined in the current configuration.
5712
- * Also logs relevant events for debugging and error tracking.
5713
- *
5714
- * @template TKey - The key of the module to require, constrained to the keys of the combined modules instance type.
5715
- * @param name - The name of the module to require.
5716
- * @param wait - The maximum time to wait (in seconds) for the module to initialize before timing out. Defaults to 60 seconds.
5717
- * @returns A Promise that resolves with the initialized module instance of type `ModulesInstanceType<CombinedModules<T, TModules>>[TKey]`.
5718
- * @throws {Error} If the module name is not defined.
5719
- * @throws {RequiredModuleTimeoutError} If the module does not initialize within the specified timeout.
5720
- *
5721
- * @example
5722
- * ```typescript
5723
- * const myModule = await requireInstance('myModuleName', 30);
5724
- * ```
5725
- */
5726
- const requireInstance = (name, wait = 60) => {
5727
- /** if module name is not defined, throw error */
5728
- if (!moduleNames.includes(name)) {
5729
- const error = new Error(`Cannot require [${String(name)}] since module is not defined!`);
5730
- error.name = 'ModuleNotDefinedError';
5731
- this._registerEvent({
5732
- level: ModuleEventLevel.Error,
5733
- name: '_initialize.requireInstance.moduleNotDefined',
5734
- message: error.message,
5735
- properties: {
5736
- moduleName: String(name),
5737
- wait,
5738
- },
5739
- error,
5740
- });
5741
- throw error;
5742
- }
5743
- /** if module is already initialized, return it */
5744
- if (instance$.value[name]) {
5745
- this._registerEvent({
5746
- level: ModuleEventLevel.Debug,
5747
- name: '_initialize.requireInstance.moduleAlreadyInitialized',
5748
- message: `Module [${String(name)}] is already initialized, skipping queue`,
5749
- properties: {
5750
- moduleName: String(name),
5751
- wait,
5752
- },
5753
- });
5754
- return Promise.resolve(instance$.value[name]);
5755
- }
5756
- const requireStart = performance.now();
5757
- this._registerEvent({
5758
- level: ModuleEventLevel.Debug,
5759
- name: '_initialize.requireInstance.awaiting',
5760
- message: `Awaiting module [${String(name)}] initialization, timeout ${wait}s`,
5761
- properties: {
5762
- moduleName: String(name),
5763
- wait,
5764
- },
5765
- });
5766
- return firstValueFrom(instance$.pipe(filter((x) => !!x[name]), map$1((x) => x[name]), timeout({
5767
- each: wait * 1000,
5768
- with: () => throwError(() => {
5769
- const error = new RequiredModuleTimeoutError();
5770
- this._registerEvent({
5771
- level: ModuleEventLevel.Error,
5772
- name: '_initialize.requireInstance.timeout',
5773
- message: `Module [${String(name)}] initialization timed out after ${wait}s`,
5774
- properties: {
5775
- moduleName: String(name),
5776
- wait,
5777
- },
5778
- error,
5779
- });
5780
- return error;
5781
- }),
5782
- }), tap(() => {
5783
- const requireTime = Math.round(performance.now() - requireStart);
5784
- this._registerEvent({
5785
- level: ModuleEventLevel.Debug,
5786
- name: '_initialize.requireInstance.moduleResolved',
5787
- message: `Module [${String(name)}] required in ${requireTime}ms`,
5788
- properties: {
5789
- moduleName: String(name),
5790
- wait,
5791
- requireTime,
5792
- },
5793
- metric: requireTime,
5794
- });
5795
- })));
5796
- };
5797
- // Create observable stream to initialize modules concurrently
5798
- // Each module goes through: validation -> initialization -> result mapping
5799
- const init$ = from(this.modules).pipe(
5800
- /** Process each module individually through initialization pipeline */
5801
- mergeMap((module) => {
5802
- const key = module.name;
5803
- if (!module.initialize) {
5804
- const error = new Error(`Module ${module.name} does not have initialize method`);
5805
- error.name = 'ModuleInitializeError';
5806
- this._registerEvent({
5807
- level: ModuleEventLevel.Error,
5808
- name: '_initialize.moduleInitializeError',
5809
- message: error.message,
5810
- properties: {
5811
- moduleName: module.name,
5812
- moduleVersion: module.version?.toString() || 'unknown',
5813
- },
5814
- error,
5815
- });
5816
- throw error;
5817
- }
5818
- this._registerEvent({
5819
- level: ModuleEventLevel.Debug,
5820
- name: '_initialize.moduleInitializing',
5821
- message: `Initializing module ${module.name}`,
5822
- properties: {
5823
- moduleName: module.name,
5824
- moduleVersion: module.version?.toString() || 'unknown',
5825
- },
5826
- });
5827
- const moduleInitStart = performance.now();
5828
- return from(
5829
- // TODO: Replace Promise.resolve + from() with toObservable() for better RxJS patterns
5830
- Promise.resolve(module.initialize({
5831
- ref,
5832
- config: config[key],
5833
- // @ts-ignore
5834
- requireInstance,
5835
- hasModule,
5836
- }))).pipe(map$1((instance) => {
5837
- if (!(instance instanceof BaseModuleProvider)) {
5838
- this._registerEvent({
5839
- level: ModuleEventLevel.Warning,
5840
- name: '_initialize.providerNotBaseModuleProvider',
5841
- message: `Provider for module ${module.name} does not extend BaseModuleProvider`,
5842
- properties: {
5843
- moduleName: module.name,
5844
- moduleVersion: module.version?.toString() || 'unknown',
5845
- },
5846
- });
5847
- }
5848
- if (!instance.version) {
5849
- this._registerEvent({
5850
- level: ModuleEventLevel.Warning,
5851
- name: '_initialize.providerVersionWarning',
5852
- message: `Provider for module ${module.name} does not expose version`,
5853
- properties: {
5854
- moduleName: module.name,
5855
- moduleVersion: module.version?.toString() || 'unknown',
5856
- },
5857
- });
5858
- }
5859
- const moduleInitTime = Math.round(performance.now() - moduleInitStart);
5860
- this._registerEvent({
5861
- level: ModuleEventLevel.Debug,
5862
- name: '_initialize.moduleInitialized',
5863
- message: `Module ${module.name} initialized in ${moduleInitTime}ms`,
5864
- properties: {
5865
- moduleName: module.name,
5866
- moduleVersion: module.version?.toString() || 'unknown',
5867
- providerName: typeof instance,
5868
- providerVersion: instance.version?.toString() || 'unknown',
5869
- moduleInitTime,
5870
- },
5871
- metric: moduleInitTime,
5872
- });
5873
- return [key, instance];
5874
- }));
5875
- }));
5876
- const initStart = performance.now();
5877
- // Subscribe to module initialization stream and accumulate results
5878
- // Each successful initialization updates the shared instance object
5879
- init$
5880
- .pipe(
5881
- /** ensure that the stream is completed even if there are no modules to initialize */
5882
- defaultIfEmpty([]))
5883
- .subscribe({
5884
- next: ([name, module]) => {
5885
- // Accumulate initialized modules into the shared instance object
5886
- instance$.next(Object.assign(instance$.value, { [name]: module }));
5887
- },
5888
- error: (err) => {
5889
- this._registerEvent({
5890
- level: ModuleEventLevel.Error,
5891
- name: '_initialize.moduleInitializationError',
5892
- message: `Failed to initialize module ${err.name || 'unknown'}`,
5893
- error: err,
5894
- });
5895
- instance$.error(err);
5896
- },
5897
- complete: () => {
5898
- const loadTime = Math.round(performance.now() - initStart);
5899
- this._registerEvent({
5900
- level: ModuleEventLevel.Debug,
5901
- name: '_initialize.moduleInitializationComplete',
5902
- message: `All modules initialized in ${loadTime}ms`,
5903
- properties: {
5904
- modules: Object.keys(instance$.value).join(', '),
5905
- loadTime,
5906
- },
5907
- metric: loadTime,
5908
- });
5909
- return instance$.complete();
5910
- },
5911
- });
5912
- /** await creation of all instances */
5913
- const initStartTime = performance.now();
5914
- const instance = await lastValueFrom(instance$);
5915
- const initTime = Math.round(performance.now() - initStartTime);
5916
- this._registerEvent({
5917
- level: ModuleEventLevel.Debug,
5918
- name: '_initialize.complete',
5919
- message: `Modules instance created in ${initTime}ms`,
5920
- properties: {
5921
- modules: Object.keys(instance).join(', '),
5922
- initTime,
5923
- },
5924
- metric: initTime,
5925
- });
5926
- Object.seal(instance);
5927
- return instance;
6560
+ async _registerPlugins(instance, ref) {
6561
+ return runPluginPhase({
6562
+ plugins: this._plugins,
6563
+ teardowns: this._pluginTeardowns,
6564
+ registerEvent: this._registerEvent.bind(this),
6565
+ }, instance, ref);
5928
6566
  }
5929
6567
  /**
5930
- * Executes post-initialization tasks.
5931
- * @param instance - Initialized module instance.
5932
- * @param ref - Reference object.
6568
+ * Tears down all modules managed by this configurator.
6569
+ *
6570
+ * Delegates to {@link runDisposePhase} which calls each module's `dispose`
6571
+ * hook and then completes the internal event stream.
6572
+ *
6573
+ * @param instance - The initialized module instance to tear down.
6574
+ * @param ref - Optional reference forwarded to module dispose hooks.
6575
+ * @returns A promise resolving when all modules have been disposed.
5933
6576
  */
5934
- async _postInitialize(instance, ref) {
5935
- const { modules, _afterInit: afterInit } = this;
5936
- const postInitialize$ = from(modules).pipe(filter((module) => !!module.postInitialize), tap((module) => {
5937
- this._registerEvent({
5938
- level: ModuleEventLevel.Debug,
5939
- name: '_postInitialize.modulePostInitializing',
5940
- message: `Module ${module.name} is being post-initialized`,
5941
- properties: {
5942
- moduleName: module.name,
5943
- moduleVersion: module.version?.toString() || 'unknown',
5944
- },
5945
- });
5946
- }), mergeMap((module) => {
5947
- const postInitStart = performance.now();
5948
- return from(module.postInitialize({
5949
- ref,
5950
- modules: instance,
5951
- instance: instance[module.name],
5952
- })).pipe(tap(() => {
5953
- const postInitTime = Math.round(performance.now() - postInitStart);
5954
- this._registerEvent({
5955
- level: ModuleEventLevel.Debug,
5956
- name: '_postInitialize.modulePostInitialized',
5957
- message: `Module ${module.name} has been post-initialized in ${postInitTime}ms`,
5958
- metric: postInitTime,
5959
- properties: {
5960
- moduleName: module.name,
5961
- moduleVersion: module.version?.toString() || 'unknown',
5962
- postInitTime,
5963
- },
5964
- });
5965
- }), defaultIfEmpty(null), catchError((err) => {
5966
- this._registerEvent({
5967
- level: ModuleEventLevel.Warning,
5968
- name: '_postInitialize.modulePostInitializeError',
5969
- message: `Module ${module.name} post-initialize failed`,
5970
- properties: {
5971
- moduleName: module.name,
5972
- moduleVersion: module.version?.toString() || 'unknown',
5973
- },
5974
- error: err,
5975
- });
5976
- return EMPTY;
5977
- }));
5978
- }), defaultIfEmpty(null));
5979
- this._registerEvent({
5980
- level: ModuleEventLevel.Debug,
5981
- name: '_postInitialize.modulesPostInitializing',
5982
- message: `Post-initializing all modules [${Object.keys(instance).length}]`,
5983
- properties: {
5984
- modules: Object.keys(instance).join(', '),
5985
- },
5986
- });
5987
- const postInitStart = performance.now();
5988
- await lastValueFrom(postInitialize$);
5989
- const postInitTime = Math.round(performance.now() - postInitStart);
5990
- this._registerEvent({
5991
- level: ModuleEventLevel.Debug,
5992
- name: '_postInitialize.modulesPostInitializeComplete',
5993
- message: `Post-initialization of all modules completed in ${postInitTime}ms`,
5994
- properties: {
5995
- modules: Object.keys(instance).join(', '),
5996
- postInitTime: postInitTime,
5997
- },
5998
- metric: postInitTime,
5999
- });
6000
- if (afterInit.length) {
6001
- try {
6002
- this._registerEvent({
6003
- level: ModuleEventLevel.Debug,
6004
- name: '_postInitialize.afterInitHooks',
6005
- message: `Executing post-initialize hooks [${afterInit.length}]`,
6006
- properties: {
6007
- hooks: afterInit.map((x) => x.name || 'anonymous').join(', '),
6008
- },
6009
- });
6010
- const afterInitStart = performance.now();
6011
- await Promise.allSettled(afterInit.map((x) => Promise.resolve(x(instance))));
6012
- const afterInitTime = Math.round(performance.now() - afterInitStart);
6013
- this._registerEvent({
6014
- level: ModuleEventLevel.Debug,
6015
- name: '_postInitialize.afterInitHooksComplete',
6016
- message: `Post-initialize hooks completed in ${afterInitTime}ms`,
6017
- properties: {
6018
- hooks: afterInit.map((x) => x.name || 'anonymous').join(', '),
6019
- afterInitTime,
6020
- },
6021
- metric: afterInitTime,
6022
- });
6023
- }
6024
- catch (err) {
6025
- this._registerEvent({
6026
- level: ModuleEventLevel.Warning,
6027
- name: '_postInitialize.afterInitHooksError',
6028
- message: 'Post-initialize hooks failed',
6029
- properties: {
6030
- hooks: afterInit.map((x) => x.name || 'anonymous').join(', '),
6031
- },
6032
- error: err,
6033
- });
6034
- }
6035
- }
6036
- const postInitCompleteTime = Math.round(performance.now() - postInitStart);
6037
- this._registerEvent({
6038
- level: ModuleEventLevel.Debug,
6039
- name: '_postInitialize.complete',
6040
- message: 'Post-initialization complete',
6041
- properties: {
6042
- modules: Object.keys(instance).join(', '),
6043
- postInitCompleteTime,
6044
- },
6045
- });
6046
- }
6047
- /**
6048
- * Disposes all modules managed by this configurator.\n *\n * Calls each module\u2019s `dispose` hook (if defined) and completes the\n * internal event stream. After disposal the configurator should not be reused.\n *\n * @param instance - The initialized modules instance to tear down.\n * @param ref - Optional reference object forwarded to module dispose hooks.\n */
6049
6577
  async dispose(instance, ref) {
6050
- this._registerEvent({
6051
- level: ModuleEventLevel.Debug,
6052
- name: 'dispose',
6053
- message: 'Disposing modules instance',
6054
- properties: {
6055
- modules: Object.keys(instance).join(', '),
6056
- },
6057
- });
6058
- await Promise.allSettled(this.modules
6059
- .filter((module) => !!module.dispose)
6060
- .map(async (module) => {
6061
- if (!module.dispose)
6062
- return;
6063
- try {
6064
- await module.dispose({
6065
- ref,
6066
- modules: instance,
6067
- instance: instance[module.name],
6068
- });
6069
- this._registerEvent({
6070
- level: ModuleEventLevel.Debug,
6071
- name: 'dispose.moduleDisposed',
6072
- message: `Module ${module.name} disposed successfully`,
6073
- properties: {
6074
- moduleName: module.name,
6075
- moduleVersion: module.version?.toString() || 'unknown',
6076
- },
6077
- });
6078
- }
6079
- catch (err) {
6080
- this._registerEvent({
6081
- level: ModuleEventLevel.Warning,
6082
- name: 'dispose.moduleDisposeError',
6083
- message: `Module ${module.name} dispose failed`,
6084
- properties: {
6085
- moduleName: module.name,
6086
- moduleVersion: module.version?.toString() || 'unknown',
6087
- },
6088
- error: err,
6089
- });
6090
- }
6091
- }));
6092
- this.#event$.complete();
6578
+ return runDisposePhase({
6579
+ modules: this.modules,
6580
+ registerEvent: this._registerEvent.bind(this),
6581
+ // ReplaySubject extends Subject — dispose only needs .complete() which both have.
6582
+ event$: this.#event$,
6583
+ pluginTeardowns: this._pluginTeardowns,
6584
+ }, instance, ref);
6093
6585
  }
6094
6586
  }
6095
6587
 
@@ -21820,7 +22312,7 @@ class HttpClientConfigurator {
21820
22312
  }
21821
22313
 
21822
22314
  // Generated by genversion.
21823
- const version$6 = '8.0.1';
22315
+ const version$6 = '8.0.2';
21824
22316
 
21825
22317
  /**
21826
22318
  * Thrown when `createClient(name)` is called with an unknown client key.
@@ -24129,7 +24621,7 @@ class TelemetryConfigurator extends BaseConfigBuilder {
24129
24621
  }
24130
24622
 
24131
24623
  // Generated by genversion.
24132
- const version$5 = '5.0.2';
24624
+ const version$5 = '6.0.0';
24133
24625
 
24134
24626
  /**
24135
24627
  * Enum representing the severity levels of telemetry items.
@@ -25062,7 +25554,7 @@ configurator, options) => {
25062
25554
  });
25063
25555
  };
25064
25556
 
25065
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25557
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25066
25558
  /*
25067
25559
  * Copyright (c) Microsoft Corporation. All rights reserved.
25068
25560
  * Licensed under the MIT License.
@@ -25289,7 +25781,7 @@ const JsonWebTokenTypes = {
25289
25781
  // Token renewal offset default in seconds
25290
25782
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
25291
25783
 
25292
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25784
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25293
25785
  /*
25294
25786
  * Copyright (c) Microsoft Corporation. All rights reserved.
25295
25787
  * Licensed under the MIT License.
@@ -25341,7 +25833,7 @@ const EAR_JWE_CRYPTO = "ear_jwe_crypto";
25341
25833
  const RESOURCE = "resource";
25342
25834
  const CLI_DATA = "clidata";
25343
25835
 
25344
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25836
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25345
25837
  /*
25346
25838
  * Copyright (c) Microsoft Corporation. All rights reserved.
25347
25839
  * Licensed under the MIT License.
@@ -25372,7 +25864,7 @@ function createAuthError(code, additionalMessage) {
25372
25864
  return new AuthError(code, additionalMessage || getDefaultErrorMessage$1(code));
25373
25865
  }
25374
25866
 
25375
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25867
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25376
25868
 
25377
25869
  /*
25378
25870
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -25392,7 +25884,7 @@ function createClientConfigurationError(errorCode) {
25392
25884
  return new ClientConfigurationError(errorCode);
25393
25885
  }
25394
25886
 
25395
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25887
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25396
25888
  /*
25397
25889
  * Copyright (c) Microsoft Corporation. All rights reserved.
25398
25890
  * Licensed under the MIT License.
@@ -25472,7 +25964,7 @@ class StringUtils {
25472
25964
  }
25473
25965
  }
25474
25966
 
25475
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25967
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25476
25968
 
25477
25969
  /*
25478
25970
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -25495,7 +25987,7 @@ function createClientAuthError(errorCode, additionalMessage) {
25495
25987
  return new ClientAuthError(errorCode, additionalMessage);
25496
25988
  }
25497
25989
 
25498
- /*! @azure/msal-common v16.5.2 2026-04-28 */
25990
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25499
25991
  /*
25500
25992
  * Copyright (c) Microsoft Corporation. All rights reserved.
25501
25993
  * Licensed under the MIT License.
@@ -25517,9 +26009,10 @@ const missingSshKid = "missing_ssh_kid";
25517
26009
  const cannotSetOIDCOptions = "cannot_set_OIDCOptions";
25518
26010
  const cannotAllowPlatformBroker = "cannot_allow_platform_broker";
25519
26011
  const authorityMismatch = "authority_mismatch";
25520
- const invalidRequestMethodForEAR = "invalid_request_method_for_EAR";
26012
+ const invalidRequestMethodForEAR = "invalid_request_method_for_EAR";
26013
+ const issuerValidationFailed = "issuer_validation_failed";
25521
26014
 
25522
- /*! @azure/msal-common v16.5.2 2026-04-28 */
26015
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25523
26016
  /*
25524
26017
  * Copyright (c) Microsoft Corporation. All rights reserved.
25525
26018
  * Licensed under the MIT License.
@@ -25558,7 +26051,7 @@ const methodNotImplemented = "method_not_implemented";
25558
26051
  const resourceParameterRequired = "resource_parameter_required";
25559
26052
  const misplacedResourceParam = "misplaced_resource_parameter";
25560
26053
 
25561
- /*! @azure/msal-common v16.5.2 2026-04-28 */
26054
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25562
26055
 
25563
26056
  /*
25564
26057
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -25753,7 +26246,7 @@ class ScopeSet {
25753
26246
  }
25754
26247
  }
25755
26248
 
25756
- /*! @azure/msal-common v16.5.2 2026-04-28 */
26249
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
25757
26250
 
25758
26251
  /*
25759
26252
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26142,7 +26635,7 @@ function addResource(parameters, resource) {
26142
26635
  }
26143
26636
  }
26144
26637
 
26145
- /*! @azure/msal-common v16.5.2 2026-04-28 */
26638
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26146
26639
 
26147
26640
  /*
26148
26641
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26251,7 +26744,7 @@ function normalizeUrlForComparison(url) {
26251
26744
  }
26252
26745
  }
26253
26746
 
26254
- /*! @azure/msal-common v16.5.2 2026-04-28 */
26747
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26255
26748
 
26256
26749
  /*
26257
26750
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26290,7 +26783,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
26290
26783
  },
26291
26784
  };
26292
26785
 
26293
- /*! @azure/msal-common v16.5.2 2026-04-28 */
26786
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26294
26787
  /*
26295
26788
  * Copyright (c) Microsoft Corporation. All rights reserved.
26296
26789
  * Licensed under the MIT License.
@@ -26551,12 +27044,12 @@ class Logger {
26551
27044
  }
26552
27045
  }
26553
27046
 
26554
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27047
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26555
27048
  /* eslint-disable header/header */
26556
27049
  const name$1 = "@azure/msal-common";
26557
- const version$4 = "16.5.2";
27050
+ const version$4 = "16.6.1";
26558
27051
 
26559
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27052
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26560
27053
  /*
26561
27054
  * Copyright (c) Microsoft Corporation. All rights reserved.
26562
27055
  * Licensed under the MIT License.
@@ -26565,7 +27058,7 @@ const AzureCloudInstance = {
26565
27058
  // AzureCloudInstance is not specified.
26566
27059
  None: "none"};
26567
27060
 
26568
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27061
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26569
27062
  /*
26570
27063
  * Copyright (c) Microsoft Corporation. All rights reserved.
26571
27064
  * Licensed under the MIT License.
@@ -26648,7 +27141,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
26648
27141
  return updatedAccountInfo;
26649
27142
  }
26650
27143
 
26651
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27144
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26652
27145
 
26653
27146
  /*
26654
27147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26728,7 +27221,7 @@ function checkMaxAge(authTime, maxAge) {
26728
27221
  }
26729
27222
  }
26730
27223
 
26731
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27224
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26732
27225
 
26733
27226
  /*
26734
27227
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26885,7 +27378,7 @@ class UrlString {
26885
27378
  }
26886
27379
  }
26887
27380
 
26888
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27381
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
26889
27382
 
26890
27383
  /*
26891
27384
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -26971,6 +27464,15 @@ const rawMetdataJSON = {
26971
27464
  preferred_cache: "login.sovcloud-identity.sg",
26972
27465
  aliases: ["login.sovcloud-identity.sg"],
26973
27466
  },
27467
+ {
27468
+ preferred_network: "login.windows-ppe.net",
27469
+ preferred_cache: "login.windows-ppe.net",
27470
+ aliases: [
27471
+ "login.windows-ppe.net",
27472
+ "sts.windows-ppe.net",
27473
+ "login.microsoft-ppe.com",
27474
+ ],
27475
+ },
26974
27476
  ],
26975
27477
  },
26976
27478
  };
@@ -27042,7 +27544,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
27042
27544
  return null;
27043
27545
  }
27044
27546
 
27045
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27547
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27046
27548
  /*
27047
27549
  * Copyright (c) Microsoft Corporation. All rights reserved.
27048
27550
  * Licensed under the MIT License.
@@ -27050,7 +27552,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
27050
27552
  const cacheQuotaExceeded = "cache_quota_exceeded";
27051
27553
  const cacheErrorUnknown = "cache_error_unknown";
27052
27554
 
27053
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27555
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27054
27556
 
27055
27557
  /*
27056
27558
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -27088,7 +27590,7 @@ function createCacheError(e) {
27088
27590
  }
27089
27591
  }
27090
27592
 
27091
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27593
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27092
27594
 
27093
27595
  /*
27094
27596
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -27126,7 +27628,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
27126
27628
  };
27127
27629
  }
27128
27630
 
27129
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27631
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27130
27632
  /*
27131
27633
  * Copyright (c) Microsoft Corporation. All rights reserved.
27132
27634
  * Licensed under the MIT License.
@@ -27141,7 +27643,7 @@ const AuthorityType = {
27141
27643
  Ciam: 3,
27142
27644
  };
27143
27645
 
27144
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27646
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27145
27647
  /*
27146
27648
  * Copyright (c) Microsoft Corporation. All rights reserved.
27147
27649
  * Licensed under the MIT License.
@@ -27163,7 +27665,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
27163
27665
  return null;
27164
27666
  }
27165
27667
 
27166
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27668
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27167
27669
  /*
27168
27670
  * Copyright (c) Microsoft Corporation. All rights reserved.
27169
27671
  * Licensed under the MIT License.
@@ -27187,7 +27689,7 @@ const ProtocolMode = {
27187
27689
  EAR: "EAR",
27188
27690
  };
27189
27691
 
27190
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27692
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27191
27693
  /**
27192
27694
  * Returns the AccountInfo interface for this account.
27193
27695
  */
@@ -27362,7 +27864,7 @@ function isAccountEntity(entity) {
27362
27864
  entity.hasOwnProperty("authorityType"));
27363
27865
  }
27364
27866
 
27365
- /*! @azure/msal-common v16.5.2 2026-04-28 */
27867
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
27366
27868
 
27367
27869
  /*
27368
27870
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -28493,7 +28995,7 @@ class DefaultStorageClass extends CacheManager {
28493
28995
  }
28494
28996
  }
28495
28997
 
28496
- /*! @azure/msal-common v16.5.2 2026-04-28 */
28998
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
28497
28999
  /*
28498
29000
  * Copyright (c) Microsoft Corporation. All rights reserved.
28499
29001
  * Licensed under the MIT License.
@@ -28507,7 +29009,7 @@ class DefaultStorageClass extends CacheManager {
28507
29009
  const PerformanceEventStatus = {
28508
29010
  InProgress: 1};
28509
29011
 
28510
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29012
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
28511
29013
 
28512
29014
  /*
28513
29015
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -28562,7 +29064,7 @@ class StubPerformanceClient {
28562
29064
  }
28563
29065
  }
28564
29066
 
28565
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29067
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
28566
29068
 
28567
29069
  /*
28568
29070
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -28657,7 +29159,7 @@ function isOidcProtocolMode(config) {
28657
29159
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
28658
29160
  }
28659
29161
 
28660
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29162
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
28661
29163
  /*
28662
29164
  * Copyright (c) Microsoft Corporation. All rights reserved.
28663
29165
  * Licensed under the MIT License.
@@ -28684,7 +29186,7 @@ function isOidcProtocolMode(config) {
28684
29186
  }
28685
29187
  }
28686
29188
 
28687
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29189
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
28688
29190
  /*
28689
29191
  * Copyright (c) Microsoft Corporation. All rights reserved.
28690
29192
  * Licensed under the MIT License.
@@ -28749,7 +29251,7 @@ function wasClockTurnedBack(cachedAt) {
28749
29251
  return cachedAtSec > nowSeconds();
28750
29252
  }
28751
29253
 
28752
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29254
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
28753
29255
 
28754
29256
  /*
28755
29257
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29008,7 +29510,7 @@ function isAuthorityMetadataExpired(metadata) {
29008
29510
  return metadata.expiresAt <= nowSeconds();
29009
29511
  }
29010
29512
 
29011
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29513
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29012
29514
  /*
29013
29515
  * Copyright (c) Microsoft Corporation. All rights reserved.
29014
29516
  * Licensed under the MIT License.
@@ -29079,7 +29581,7 @@ const RegionDiscoveryGetCurrentVersion = "regionDiscoveryGetCurrentVersion";
29079
29581
  const CacheManagerGetRefreshToken = "cacheManagerGetRefreshToken";
29080
29582
  const SetUserData = "setUserData";
29081
29583
 
29082
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29584
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29083
29585
  /*
29084
29586
  * Copyright (c) Microsoft Corporation. All rights reserved.
29085
29587
  * Licensed under the MIT License.
@@ -29172,7 +29674,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
29172
29674
  };
29173
29675
  };
29174
29676
 
29175
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29677
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29176
29678
 
29177
29679
  /*
29178
29680
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29252,7 +29754,7 @@ class PopTokenGenerator {
29252
29754
  }
29253
29755
  }
29254
29756
 
29255
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29757
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29256
29758
  /*
29257
29759
  * Copyright (c) Microsoft Corporation. All rights reserved.
29258
29760
  * Licensed under the MIT License.
@@ -29303,7 +29805,7 @@ const badToken = "bad_token";
29303
29805
  */
29304
29806
  const interruptedUser = "interrupted_user";
29305
29807
 
29306
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29808
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29307
29809
 
29308
29810
  /*
29309
29811
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29371,7 +29873,7 @@ function createInteractionRequiredAuthError(errorCode, errorMessage) {
29371
29873
  return new InteractionRequiredAuthError(errorCode, errorMessage);
29372
29874
  }
29373
29875
 
29374
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29876
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29375
29877
 
29376
29878
  /*
29377
29879
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29390,7 +29892,7 @@ class ServerError extends AuthError {
29390
29892
  }
29391
29893
  }
29392
29894
 
29393
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29895
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29394
29896
 
29395
29897
  /*
29396
29898
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29458,7 +29960,7 @@ function parseRequestState(base64Decode, state) {
29458
29960
  }
29459
29961
  }
29460
29962
 
29461
- /*! @azure/msal-common v16.5.2 2026-04-28 */
29963
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29462
29964
 
29463
29965
  /*
29464
29966
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29806,7 +30308,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
29806
30308
  return baseAccount;
29807
30309
  }
29808
30310
 
29809
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30311
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29810
30312
  /*
29811
30313
  * Copyright (c) Microsoft Corporation. All rights reserved.
29812
30314
  * Licensed under the MIT License.
@@ -29816,7 +30318,7 @@ const CcsCredentialType = {
29816
30318
  UPN: "UPN",
29817
30319
  };
29818
30320
 
29819
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30321
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29820
30322
  /*
29821
30323
  * Copyright (c) Microsoft Corporation. All rights reserved.
29822
30324
  * Licensed under the MIT License.
@@ -29834,7 +30336,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
29834
30336
  }
29835
30337
  }
29836
30338
 
29837
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30339
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29838
30340
  /*
29839
30341
  * Copyright (c) Microsoft Corporation. All rights reserved.
29840
30342
  * Licensed under the MIT License.
@@ -29855,7 +30357,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
29855
30357
  };
29856
30358
  }
29857
30359
 
29858
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30360
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29859
30361
 
29860
30362
  /*
29861
30363
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29941,7 +30443,7 @@ class ThrottlingUtils {
29941
30443
  }
29942
30444
  }
29943
30445
 
29944
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30446
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29945
30447
 
29946
30448
  /*
29947
30449
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -29972,7 +30474,7 @@ function createNetworkError(error, httpStatus, responseHeaders, additionalError)
29972
30474
  return new NetworkError(error, httpStatus, responseHeaders);
29973
30475
  }
29974
30476
 
29975
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30477
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
29976
30478
 
29977
30479
  /*
29978
30480
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -30086,7 +30588,7 @@ async function sendPostRequest(thumbprint, tokenEndpoint, options, correlationId
30086
30588
  return response;
30087
30589
  }
30088
30590
 
30089
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30591
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
30090
30592
  /*
30091
30593
  * Copyright (c) Microsoft Corporation. All rights reserved.
30092
30594
  * Licensed under the MIT License.
@@ -30098,7 +30600,7 @@ function isOpenIdConfigResponse(response) {
30098
30600
  response.hasOwnProperty("jwks_uri"));
30099
30601
  }
30100
30602
 
30101
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30603
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
30102
30604
  /*
30103
30605
  * Copyright (c) Microsoft Corporation. All rights reserved.
30104
30606
  * Licensed under the MIT License.
@@ -30108,7 +30610,7 @@ function isCloudInstanceDiscoveryResponse(response) {
30108
30610
  response.hasOwnProperty("metadata"));
30109
30611
  }
30110
30612
 
30111
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30613
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
30112
30614
  /*
30113
30615
  * Copyright (c) Microsoft Corporation. All rights reserved.
30114
30616
  * Licensed under the MIT License.
@@ -30118,7 +30620,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
30118
30620
  response.hasOwnProperty("error_description"));
30119
30621
  }
30120
30622
 
30121
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30623
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
30122
30624
 
30123
30625
  /*
30124
30626
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -30223,7 +30725,7 @@ RegionDiscovery.IMDS_OPTIONS = {
30223
30725
  },
30224
30726
  };
30225
30727
 
30226
- /*! @azure/msal-common v16.5.2 2026-04-28 */
30728
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
30227
30729
 
30228
30730
  /*
30229
30731
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -30478,7 +30980,7 @@ class Authority {
30478
30980
  }, this.correlationId);
30479
30981
  }
30480
30982
  /**
30481
- * Returns metadata entity from cache if it exists, otherwiser returns a new metadata entity built
30983
+ * Returns metadata entity from cache if it exists, otherwise returns a new metadata entity built
30482
30984
  * from the configured canonical authority
30483
30985
  * @returns
30484
30986
  */
@@ -30547,6 +31049,8 @@ class Authority {
30547
31049
  // Get metadata from network if local sources aren't available
30548
31050
  let metadata = await invokeAsync(this.getEndpointMetadataFromNetwork.bind(this), AuthorityGetEndpointMetadataFromNetwork, this.logger, this.performanceClient, this.correlationId)();
30549
31051
  if (metadata) {
31052
+ // Validate the issuer returned by the OIDC discovery document.
31053
+ this.validateIssuer(metadata.issuer);
30550
31054
  // If the user prefers to use an azure region replace the global endpoints with regional information.
30551
31055
  if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
30552
31056
  metadata = await invokeAsync(this.updateMetadataWithRegionalInformation.bind(this), AuthorityUpdateMetadataWithRegionalInformation, this.logger, this.performanceClient, this.correlationId)(metadata);
@@ -30715,7 +31219,7 @@ class Authority {
30715
31219
  throw createClientConfigurationError(untrustedAuthority);
30716
31220
  }
30717
31221
  updateCloudDiscoveryMetadataFromLocalSources(metadataEntity) {
30718
- this.logger.verbose("0jhlgt", this.correlationId);
31222
+ this.logger.verbose("1tpqlr", this.correlationId);
30719
31223
  this.logger.verbosePii("1fy7uz", this.correlationId);
30720
31224
  this.logger.verbosePii("08zabj", this.correlationId);
30721
31225
  this.logger.verbosePii("1o1kv3", this.correlationId);
@@ -30912,6 +31416,139 @@ class Authority {
30912
31416
  isAliasOfKnownMicrosoftAuthority(host) {
30913
31417
  return InstanceDiscoveryMetadataAliases.has(host);
30914
31418
  }
31419
+ /**
31420
+ * Validates the `issuer` returned by an OIDC discovery document against
31421
+ * this authority, per
31422
+ * https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationValidation
31423
+ *
31424
+ * The issuer is accepted when ANY of the following holds:
31425
+ * 1. The issuer scheme + host + port match the authority's (path may
31426
+ * differ). Applies to all authorities.
31427
+ * 2. The authority is a Microsoft cloud authority (public, sovereign,
31428
+ * or CIAM), the issuer is HTTPS, and the issuer host is in the known
31429
+ * Microsoft authority host set.
31430
+ * 3. Same as (2), but the issuer host is a single-label regional variant
31431
+ * of a known Microsoft host (e.g. `westus.login.microsoftonline.com`).
31432
+ * 4. Same as (2), but the issuer host matches the CIAM tenant pattern
31433
+ * `{tenant}.ciamlogin.com` with an optional `/{tenant}[.onmicrosoft.com][/v2.0]`
31434
+ * path.
31435
+ *
31436
+ * @param issuer The `issuer` value returned in the OIDC discovery document.
31437
+ * @throws ClientConfigurationError("issuer_validation_failed") on failure.
31438
+ */
31439
+ validateIssuer(issuer) {
31440
+ if (!issuer) {
31441
+ throw createClientConfigurationError(issuerValidationFailed);
31442
+ }
31443
+ // Parse with the WHATWG URL API. URL normalizes scheme + host to lowercase per RFC 3986.
31444
+ let issuerUrl;
31445
+ try {
31446
+ issuerUrl = new URL(issuer);
31447
+ }
31448
+ catch {
31449
+ throw createClientConfigurationError(issuerValidationFailed);
31450
+ }
31451
+ const issuerScheme = issuerUrl.protocol;
31452
+ const issuerHost = issuerUrl.host;
31453
+ const authorityScheme = (this.canonicalAuthorityUrlComponents.Protocol || "").toLowerCase();
31454
+ const authorityHost = (this.canonicalAuthorityUrlComponents.HostNameAndPort || "").toLowerCase();
31455
+ // Rule 1: Same scheme and host
31456
+ const matchesAuthorityOrigin = this.matchesAuthorityOrigin(issuerScheme, issuerHost, authorityScheme, authorityHost);
31457
+ // Rule 2: The issuer host is a well-known Microsoft authority host (HTTPS only)
31458
+ const matchesKnownMicrosoftHost = issuerScheme === "https:" &&
31459
+ this.isAliasOfKnownMicrosoftAuthority(issuerHost);
31460
+ /*
31461
+ * Rule 3: The issuer host is a regional variant ({region}.{host}) of a well-known host
31462
+ * (HTTPS only). E.g. westus2.login.microsoft.com
31463
+ */
31464
+ const matchesRegionalMicrosoftHost = issuerScheme === "https:" &&
31465
+ this.matchesRegionalMicrosoftHost(issuerHost);
31466
+ /*
31467
+ * Rule 4: CIAM-specific validation. In a CIAM scenario the issuer is expected to
31468
+ * have "{tenant}.ciamlogin.com" as the host, even when using a custom domain.
31469
+ */
31470
+ const matchesCiamTenantPattern = this.matchesCiamTenantPattern(issuerUrl, authorityHost, this.canonicalAuthorityUrlComponents.PathSegments);
31471
+ // Each rule is an independent boolean; the issuer is valid if ANY rule matches.
31472
+ if (matchesAuthorityOrigin ||
31473
+ matchesKnownMicrosoftHost ||
31474
+ matchesRegionalMicrosoftHost ||
31475
+ matchesCiamTenantPattern) {
31476
+ return;
31477
+ }
31478
+ // issuer validation fails if none of the above rules are satisfied
31479
+ throw createClientConfigurationError(issuerValidationFailed);
31480
+ }
31481
+ /**
31482
+ * Rule 1: The issuer scheme + host (and port) match the authority's. Path
31483
+ * may differ. Applies to all authorities.
31484
+ */
31485
+ matchesAuthorityOrigin(issuerScheme, issuerHost, authorityScheme, authorityHost) {
31486
+ return issuerScheme === authorityScheme && issuerHost === authorityHost;
31487
+ }
31488
+ /**
31489
+ * Rule 3: The issuer host is a regional variant
31490
+ * (`{region}.{host}`) of a known Microsoft authority host.
31491
+ * E.g. `westus2.login.microsoft.com`.
31492
+ */
31493
+ matchesRegionalMicrosoftHost(issuerHost) {
31494
+ const firstDot = issuerHost.indexOf(".");
31495
+ if (firstDot > 0 && firstDot < issuerHost.length - 1) {
31496
+ const hostWithoutRegion = issuerHost.substring(firstDot + 1);
31497
+ return this.isAliasOfKnownMicrosoftAuthority(hostWithoutRegion);
31498
+ }
31499
+ return false;
31500
+ }
31501
+ /**
31502
+ * Rule 4: The issuer matches one of the well-known CIAM tenant patterns
31503
+ * (`https://{tenant}.ciamlogin.com[/{tenant}[.onmicrosoft.com][/v2.0]]`).
31504
+ *
31505
+ * The bare tenant name is extracted from the authority's first path segment
31506
+ * when available (stripping the `.onmicrosoft.com` suffix that
31507
+ * `transformCIAMAuthority` adds), or otherwise from the leftmost label of
31508
+ * the authority host (to support CIAM custom domain scenarios).
31509
+ *
31510
+ * Both `/{tenant}` and `/{tenant}.onmicrosoft.com` path forms are accepted
31511
+ * because the OIDC issuer may use either form depending on the authority URL
31512
+ * that was used to trigger discovery.
31513
+ */
31514
+ matchesCiamTenantPattern(issuerUrl, authorityHost, authorityPathSegments) {
31515
+ /*
31516
+ * authorityPathSegments[0] is the first path segment of the *authority
31517
+ * URL* after transformCIAMAuthority runs (e.g. "contoso.onmicrosoft.com").
31518
+ * Additional CIAM issuer path segments such as "/v2.0" are part of the
31519
+ * issuer string, not the authority URL's PathSegments.
31520
+ */
31521
+ const pathSegment = authorityPathSegments[0];
31522
+ /*
31523
+ * Extract the bare tenant name: strip the .onmicrosoft.com suffix when
31524
+ * present (introduced by transformCIAMAuthority), or fall back to the
31525
+ * first label of the authority hostname for non-transformed/custom-domain
31526
+ * CIAM authorities.
31527
+ */
31528
+ const tenantName = pathSegment
31529
+ ? pathSegment.endsWith(AAD_TENANT_DOMAIN_SUFFIX)
31530
+ ? pathSegment.slice(0, -AAD_TENANT_DOMAIN_SUFFIX.length)
31531
+ : pathSegment
31532
+ : authorityHost.split(".")[0];
31533
+ if (!tenantName) {
31534
+ return false;
31535
+ }
31536
+ const ciamBaseURL = `https://${tenantName}${CIAM_AUTH_URL}`;
31537
+ const validCiamPatterns = [
31538
+ ciamBaseURL,
31539
+ `${ciamBaseURL}/${tenantName}`,
31540
+ `${ciamBaseURL}/${tenantName}/v2.0`,
31541
+ `${ciamBaseURL}/${tenantName}${AAD_TENANT_DOMAIN_SUFFIX}`,
31542
+ `${ciamBaseURL}/${tenantName}${AAD_TENANT_DOMAIN_SUFFIX}/v2.0`, // https://{tenant}.ciamlogin.com/{tenant}.onmicrosoft.com/v2.0
31543
+ ];
31544
+ /*
31545
+ * Compose the canonical issuer string from URL components and strip any
31546
+ * trailing slashes from the path so it can be compared to the pattern set.
31547
+ */
31548
+ const issuerPath = issuerUrl.pathname.replace(/\/+$/, "");
31549
+ const normalizedIssuer = `${issuerUrl.protocol}//${issuerUrl.host}${issuerPath}`;
31550
+ return validCiamPatterns.some((pattern) => pattern === normalizedIssuer);
31551
+ }
30915
31552
  /**
30916
31553
  * Checks whether the provided host is that of a public cloud authority
30917
31554
  *
@@ -31043,7 +31680,7 @@ function buildStaticAuthorityOptions(authOptions) {
31043
31680
  };
31044
31681
  }
31045
31682
 
31046
- /*! @azure/msal-common v16.5.2 2026-04-28 */
31683
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31047
31684
 
31048
31685
  /*
31049
31686
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31077,7 +31714,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
31077
31714
  }
31078
31715
  }
31079
31716
 
31080
- /*! @azure/msal-common v16.5.2 2026-04-28 */
31717
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31081
31718
 
31082
31719
  /*
31083
31720
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31334,7 +31971,7 @@ class AuthorizationCodeClient {
31334
31971
  }
31335
31972
  }
31336
31973
 
31337
- /*! @azure/msal-common v16.5.2 2026-04-28 */
31974
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31338
31975
 
31339
31976
  /*
31340
31977
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31555,7 +32192,7 @@ class RefreshTokenClient {
31555
32192
  }
31556
32193
  }
31557
32194
 
31558
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32195
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31559
32196
 
31560
32197
  /*
31561
32198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31671,7 +32308,7 @@ class SilentFlowClient {
31671
32308
  }
31672
32309
  }
31673
32310
 
31674
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32311
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31675
32312
 
31676
32313
  /*
31677
32314
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31686,7 +32323,7 @@ const StubbedNetworkModule = {
31686
32323
  },
31687
32324
  };
31688
32325
 
31689
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32326
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31690
32327
 
31691
32328
  /*
31692
32329
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31909,7 +32546,7 @@ function extractLoginHint(account) {
31909
32546
  return account.loginHint || account.idTokenClaims?.login_hint || null;
31910
32547
  }
31911
32548
 
31912
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32549
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31913
32550
 
31914
32551
  /*
31915
32552
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -31942,7 +32579,7 @@ function containsResourceParam(params) {
31942
32579
  return Object.prototype.hasOwnProperty.call(params, "resource");
31943
32580
  }
31944
32581
 
31945
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32582
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31946
32583
  /*
31947
32584
  * Copyright (c) Microsoft Corporation. All rights reserved.
31948
32585
  * Licensed under the MIT License.
@@ -31952,7 +32589,7 @@ function containsResourceParam(params) {
31952
32589
  */
31953
32590
  const unexpectedError = "unexpected_error";
31954
32591
 
31955
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32592
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
31956
32593
 
31957
32594
  /*
31958
32595
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -32213,7 +32850,7 @@ class ServerTelemetryManager {
32213
32850
  }
32214
32851
  }
32215
32852
 
32216
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32853
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
32217
32854
 
32218
32855
  /*
32219
32856
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -32234,7 +32871,7 @@ function createJoseHeaderError(code) {
32234
32871
  return new JoseHeaderError(code);
32235
32872
  }
32236
32873
 
32237
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32874
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
32238
32875
  /*
32239
32876
  * Copyright (c) Microsoft Corporation. All rights reserved.
32240
32877
  * Licensed under the MIT License.
@@ -32242,7 +32879,7 @@ function createJoseHeaderError(code) {
32242
32879
  const missingKidError = "missing_kid_error";
32243
32880
  const missingAlgError = "missing_alg_error";
32244
32881
 
32245
- /*! @azure/msal-common v16.5.2 2026-04-28 */
32882
+ /*! @azure/msal-common v16.6.1 2026-05-11 */
32246
32883
 
32247
32884
  /*
32248
32885
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -32282,7 +32919,7 @@ class JoseHeader {
32282
32919
  }
32283
32920
  }
32284
32921
 
32285
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
32922
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32286
32923
  /*
32287
32924
  * Copyright (c) Microsoft Corporation. All rights reserved.
32288
32925
  * Licensed under the MIT License.
@@ -32410,7 +33047,7 @@ const DecryptEarResponse = "decryptEarResponse";
32410
33047
  */
32411
33048
  const WaitForBridgeLateResponse = "waitForBridgeLateResponse";
32412
33049
 
32413
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33050
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32414
33051
 
32415
33052
  /*
32416
33053
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -32433,7 +33070,7 @@ function createBrowserAuthError(errorCode, subError) {
32433
33070
  return new BrowserAuthError(errorCode, subError);
32434
33071
  }
32435
33072
 
32436
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33073
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32437
33074
 
32438
33075
  /*
32439
33076
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -32619,7 +33256,7 @@ const iFrameRenewalPolicies = [
32619
33256
  CacheLookupPolicy.RefreshTokenAndNetwork,
32620
33257
  ];
32621
33258
 
32622
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33259
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32623
33260
  /*
32624
33261
  * Copyright (c) Microsoft Corporation. All rights reserved.
32625
33262
  * Licensed under the MIT License.
@@ -32664,7 +33301,7 @@ function base64EncArr(aBytes) {
32664
33301
  return btoa(binString);
32665
33302
  }
32666
33303
 
32667
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33304
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32668
33305
  /*
32669
33306
  * Copyright (c) Microsoft Corporation. All rights reserved.
32670
33307
  * Licensed under the MIT License.
@@ -32717,7 +33354,7 @@ const failedToDecryptEarResponse = "failed_to_decrypt_ear_response";
32717
33354
  const timedOut = "timed_out";
32718
33355
  const emptyResponse = "empty_response";
32719
33356
 
32720
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33357
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32721
33358
 
32722
33359
  /*
32723
33360
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -32756,7 +33393,7 @@ function base64DecToArr(base64String) {
32756
33393
  return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
32757
33394
  }
32758
33395
 
32759
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33396
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
32760
33397
 
32761
33398
  /*
32762
33399
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -33054,7 +33691,7 @@ async function hashString(plainText) {
33054
33691
  return urlEncodeArr(hashBytes);
33055
33692
  }
33056
33693
 
33057
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33694
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33058
33695
 
33059
33696
  /*
33060
33697
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -33074,7 +33711,7 @@ function createBrowserConfigurationAuthError(errorCode) {
33074
33711
  return new BrowserConfigurationAuthError(errorCode, getDefaultErrorMessage(errorCode));
33075
33712
  }
33076
33713
 
33077
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33714
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33078
33715
  /*
33079
33716
  * Copyright (c) Microsoft Corporation. All rights reserved.
33080
33717
  * Licensed under the MIT License.
@@ -33082,7 +33719,7 @@ function createBrowserConfigurationAuthError(errorCode) {
33082
33719
  const storageNotSupported = "storage_not_supported";
33083
33720
  const inMemRedirectUnavailable = "in_mem_redirect_unavailable";
33084
33721
 
33085
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
33722
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33086
33723
 
33087
33724
  /*
33088
33725
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -33417,7 +34054,7 @@ function createGuid() {
33417
34054
  return createNewGuid();
33418
34055
  }
33419
34056
 
33420
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34057
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33421
34058
 
33422
34059
  /*
33423
34060
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -33620,7 +34257,7 @@ class DatabaseStorage {
33620
34257
  }
33621
34258
  }
33622
34259
 
33623
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34260
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33624
34261
  /*
33625
34262
  * Copyright (c) Microsoft Corporation. All rights reserved.
33626
34263
  * Licensed under the MIT License.
@@ -33666,7 +34303,7 @@ class MemoryStorage {
33666
34303
  }
33667
34304
  }
33668
34305
 
33669
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34306
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33670
34307
 
33671
34308
  /*
33672
34309
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -33807,7 +34444,7 @@ class AsyncMemoryStorage {
33807
34444
  }
33808
34445
  }
33809
34446
 
33810
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34447
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33811
34448
 
33812
34449
  /*
33813
34450
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -33990,7 +34627,7 @@ function getSortedObjectString(obj) {
33990
34627
  return JSON.stringify(obj, Object.keys(obj).sort());
33991
34628
  }
33992
34629
 
33993
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34630
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
33994
34631
  /*
33995
34632
  * Copyright (c) Microsoft Corporation. All rights reserved.
33996
34633
  * Licensed under the MIT License.
@@ -34037,7 +34674,7 @@ const LocalStorageUpdated = "localStorageUpdated";
34037
34674
  */
34038
34675
  const SsoCapable = "ssoCapable";
34039
34676
 
34040
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34677
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34041
34678
  /*
34042
34679
  * Copyright (c) Microsoft Corporation. All rights reserved.
34043
34680
  * Licensed under the MIT License.
@@ -34067,7 +34704,7 @@ function getTokenKeysCacheKey(clientId, schema = CREDENTIAL_SCHEMA_VERSION) {
34067
34704
  return `${PREFIX}.${schema}.${TOKEN_KEYS}.${clientId}`;
34068
34705
  }
34069
34706
 
34070
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34707
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34071
34708
 
34072
34709
  /*
34073
34710
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -34158,7 +34795,7 @@ function getCookieExpirationTime(cookieLifeDays) {
34158
34795
  return expr.toUTCString();
34159
34796
  }
34160
34797
 
34161
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34798
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34162
34799
 
34163
34800
  /*
34164
34801
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -34200,7 +34837,7 @@ function getTokenKeys(clientId, storage, schemaVersion) {
34200
34837
  };
34201
34838
  }
34202
34839
 
34203
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34840
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34204
34841
  /*
34205
34842
  * Copyright (c) Microsoft Corporation. All rights reserved.
34206
34843
  * Licensed under the MIT License.
@@ -34211,7 +34848,7 @@ function isEncrypted(data) {
34211
34848
  data.hasOwnProperty("data"));
34212
34849
  }
34213
34850
 
34214
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
34851
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34215
34852
 
34216
34853
  /*
34217
34854
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -34503,7 +35140,7 @@ class LocalStorage {
34503
35140
  }
34504
35141
  }
34505
35142
 
34506
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
35143
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34507
35144
 
34508
35145
  /*
34509
35146
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -34545,7 +35182,7 @@ class SessionStorage {
34545
35182
  }
34546
35183
  }
34547
35184
 
34548
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
35185
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34549
35186
  /*
34550
35187
  * Copyright (c) Microsoft Corporation. All rights reserved.
34551
35188
  * Licensed under the MIT License.
@@ -34573,12 +35210,12 @@ const EventType = {
34573
35210
  BROKER_CONNECTION_ESTABLISHED: "msal:brokerConnectionEstablished",
34574
35211
  };
34575
35212
 
34576
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
35213
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34577
35214
  /* eslint-disable header/header */
34578
35215
  const name = "@azure/msal-browser";
34579
- const version$3 = "5.9.0";
35216
+ const version$3 = "5.10.1";
34580
35217
 
34581
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
35218
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34582
35219
  /*
34583
35220
  * Copyright (c) Microsoft Corporation. All rights reserved.
34584
35221
  * Licensed under the MIT License.
@@ -34595,7 +35232,7 @@ function removeElementFromArray(array, element) {
34595
35232
  }
34596
35233
  }
34597
35234
 
34598
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
35235
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
34599
35236
 
34600
35237
  /*
34601
35238
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -35632,22 +36269,9 @@ class BrowserCacheManager extends CacheManager {
35632
36269
  * @param generateKey
35633
36270
  */
35634
36271
  getTemporaryCache(cacheKey, correlationId, generateKey) {
36272
+ this.logger.trace("1ordf8", correlationId);
35635
36273
  const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
35636
- const value = this.temporaryCacheStorage.getItem(key);
35637
- if (!value) {
35638
- // If temp cache item not found in session/memory, check local storage for items set by old versions
35639
- if (this.cacheConfig.cacheLocation ===
35640
- BrowserCacheLocation.LocalStorage) {
35641
- const item = this.browserStorage.getItem(key);
35642
- if (item) {
35643
- this.logger.trace("1yt61y", correlationId);
35644
- return item;
35645
- }
35646
- }
35647
- this.logger.trace("1qhy81", correlationId);
35648
- return null;
35649
- }
35650
- return value;
36274
+ return this.temporaryCacheStorage.getItem(key);
35651
36275
  }
35652
36276
  /**
35653
36277
  * Sets the cache item with the key and value given.
@@ -35960,7 +36584,7 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger, performanceClient, even
35960
36584
  return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger, performanceClient, eventHandler);
35961
36585
  };
35962
36586
 
35963
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
36587
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
35964
36588
  /*
35965
36589
  * Copyright (c) Microsoft Corporation. All rights reserved.
35966
36590
  * Licensed under the MIT License.
@@ -36007,7 +36631,7 @@ function getActiveAccount(browserStorage, correlationId) {
36007
36631
  return browserStorage.getActiveAccount(correlationId);
36008
36632
  }
36009
36633
 
36010
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
36634
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36011
36635
 
36012
36636
  /*
36013
36637
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36111,7 +36735,7 @@ class EventHandler {
36111
36735
  }
36112
36736
  }
36113
36737
 
36114
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
36738
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36115
36739
 
36116
36740
  /*
36117
36741
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36246,7 +36870,7 @@ async function clearCacheOnLogout(browserStorage, browserCrypto, logger, correla
36246
36870
  }
36247
36871
  }
36248
36872
 
36249
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
36873
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36250
36874
 
36251
36875
  /*
36252
36876
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36324,7 +36948,7 @@ function validateRequestMethod(interactionRequest, protocolMode) {
36324
36948
  return httpMethod;
36325
36949
  }
36326
36950
 
36327
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
36951
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36328
36952
 
36329
36953
  /*
36330
36954
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36528,7 +37152,7 @@ async function initializeAuthorizationRequest(request, interactionType, config,
36528
37152
  return validatedRequest;
36529
37153
  }
36530
37154
 
36531
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37155
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36532
37156
 
36533
37157
  /*
36534
37158
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36552,7 +37176,7 @@ function extractBrowserRequestState(browserCrypto, state) {
36552
37176
  }
36553
37177
  }
36554
37178
 
36555
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37179
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36556
37180
 
36557
37181
  /*
36558
37182
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36591,7 +37215,7 @@ function validateInteractionType(response, browserCrypto, interactionType) {
36591
37215
  }
36592
37216
  }
36593
37217
 
36594
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37218
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36595
37219
 
36596
37220
  /*
36597
37221
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36680,7 +37304,7 @@ class InteractionHandler {
36680
37304
  }
36681
37305
  }
36682
37306
 
36683
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37307
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36684
37308
  /*
36685
37309
  * Copyright (c) Microsoft Corporation. All rights reserved.
36686
37310
  * Licensed under the MIT License.
@@ -36689,7 +37313,7 @@ const contentError = "ContentError";
36689
37313
  const pageException = "PageException";
36690
37314
  const userSwitch = "user_switch";
36691
37315
 
36692
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37316
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36693
37317
  /*
36694
37318
  * Copyright (c) Microsoft Corporation. All rights reserved.
36695
37319
  * Licensed under the MIT License.
@@ -36702,7 +37326,7 @@ const DISABLED = "DISABLED";
36702
37326
  const ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE";
36703
37327
  const UX_NOT_ALLOWED = "UX_NOT_ALLOWED";
36704
37328
 
36705
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37329
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36706
37330
 
36707
37331
  /*
36708
37332
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36764,7 +37388,7 @@ function createNativeAuthError(code, description, ext) {
36764
37388
  return new NativeAuthError(code, description, ext);
36765
37389
  }
36766
37390
 
36767
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37391
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36768
37392
 
36769
37393
  /*
36770
37394
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -36813,7 +37437,7 @@ class SilentCacheClient extends StandardInteractionClient {
36813
37437
  }
36814
37438
  }
36815
37439
 
36816
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
37440
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
36817
37441
 
36818
37442
  /*
36819
37443
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -37444,7 +38068,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
37444
38068
  }
37445
38069
  }
37446
38070
 
37447
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38071
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
37448
38072
 
37449
38073
  /*
37450
38074
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -37744,7 +38368,7 @@ async function handleResponseEAR(request, response, apiId, config, authority, br
37744
38368
  return (await invokeAsync(responseHandler.handleServerTokenResponse.bind(responseHandler), HandleServerTokenResponse, logger, performanceClient, request.correlationId)(decryptedData, authority, nowSeconds(), request, apiId, additionalData, undefined, undefined, undefined, undefined));
37745
38369
  }
37746
38370
 
37747
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38371
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
37748
38372
 
37749
38373
  /*
37750
38374
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -37799,7 +38423,7 @@ async function generateCodeChallengeFromVerifier(pkceCodeVerifier, performanceCl
37799
38423
  }
37800
38424
  }
37801
38425
 
37802
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38426
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
37803
38427
 
37804
38428
  /*
37805
38429
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -37842,7 +38466,7 @@ class NavigationClient {
37842
38466
  }
37843
38467
  }
37844
38468
 
37845
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38469
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
37846
38470
 
37847
38471
  /*
37848
38472
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -37963,7 +38587,7 @@ function getHeaderDict(headers) {
37963
38587
  }
37964
38588
  }
37965
38589
 
37966
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38590
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
37967
38591
 
37968
38592
  /*
37969
38593
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -38091,7 +38715,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
38091
38715
  return overlayedConfig;
38092
38716
  }
38093
38717
 
38094
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38718
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
38095
38719
 
38096
38720
  /*
38097
38721
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -38352,7 +38976,7 @@ class PlatformAuthExtensionHandler {
38352
38976
  }
38353
38977
  }
38354
38978
 
38355
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
38979
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
38356
38980
 
38357
38981
  /*
38358
38982
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -38502,7 +39126,7 @@ class PlatformAuthDOMHandler {
38502
39126
  }
38503
39127
  }
38504
39128
 
38505
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
39129
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
38506
39130
  async function getPlatformAuthProvider(logger, performanceClient, correlationId, nativeBrokerHandshakeTimeout) {
38507
39131
  logger.trace("134j0v", correlationId);
38508
39132
  const enablePlatformBrokerDOMSupport = isDomEnabledForPlatformAuth();
@@ -38579,7 +39203,7 @@ function isPlatformAuthAllowed(config, logger, correlationId, platformAuthProvid
38579
39203
  return true;
38580
39204
  }
38581
39205
 
38582
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
39206
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
38583
39207
 
38584
39208
  /*
38585
39209
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -38999,7 +39623,7 @@ class PopupClient extends StandardInteractionClient {
38999
39623
  }
39000
39624
  }
39001
39625
 
39002
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
39626
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39003
39627
 
39004
39628
  /*
39005
39629
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -39434,7 +40058,7 @@ class RedirectClient extends StandardInteractionClient {
39434
40058
  }
39435
40059
  }
39436
40060
 
39437
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40061
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39438
40062
 
39439
40063
  /*
39440
40064
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -39511,7 +40135,7 @@ function removeHiddenIframe(iframe) {
39511
40135
  }
39512
40136
  }
39513
40137
 
39514
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40138
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39515
40139
 
39516
40140
  /*
39517
40141
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -39718,7 +40342,7 @@ class SilentIframeClient extends StandardInteractionClient {
39718
40342
  }
39719
40343
  }
39720
40344
 
39721
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40345
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39722
40346
 
39723
40347
  /*
39724
40348
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -39783,7 +40407,7 @@ class SilentRefreshClient extends StandardInteractionClient {
39783
40407
  }
39784
40408
  }
39785
40409
 
39786
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40410
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39787
40411
 
39788
40412
  /*
39789
40413
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -39796,7 +40420,7 @@ class HybridSpaAuthorizationCodeClient extends AuthorizationCodeClient {
39796
40420
  }
39797
40421
  }
39798
40422
 
39799
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40423
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39800
40424
 
39801
40425
  /*
39802
40426
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -39867,7 +40491,7 @@ class SilentAuthCodeClient extends StandardInteractionClient {
39867
40491
  }
39868
40492
  }
39869
40493
 
39870
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40494
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39871
40495
  function collectInstanceStats(currentClientId, performanceEvent, logger, correlationId) {
39872
40496
  const frameInstances =
39873
40497
  // @ts-ignore
@@ -39883,7 +40507,7 @@ function collectInstanceStats(currentClientId, performanceEvent, logger, correla
39883
40507
  });
39884
40508
  }
39885
40509
 
39886
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
40510
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
39887
40511
 
39888
40512
  /*
39889
40513
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -41370,7 +41994,7 @@ function checkIfRefreshTokenErrorCanBeResolvedSilently(refreshTokenError, cacheL
41370
41994
  return isSilentlyResolvable && tryIframeRenewal;
41371
41995
  }
41372
41996
 
41373
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
41997
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
41374
41998
 
41375
41999
  /*
41376
42000
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -41467,7 +42091,7 @@ class BaseOperatingContext {
41467
42091
  }
41468
42092
  }
41469
42093
 
41470
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
42094
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
41471
42095
 
41472
42096
  /*
41473
42097
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -41514,7 +42138,7 @@ StandardOperatingContext.MODULE_NAME = "";
41514
42138
  */
41515
42139
  StandardOperatingContext.ID = "StandardOperatingContext";
41516
42140
 
41517
- /*! @azure/msal-browser v5.9.0 2026-04-28 */
42141
+ /*! @azure/msal-browser v5.10.1 2026-05-11 */
41518
42142
 
41519
42143
  /*
41520
42144
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -41812,6 +42436,7 @@ const FUSION_CORRELATION_ID = '';
41812
42436
  class MsalClient extends PublicClientApplication {
41813
42437
  #tenantId;
41814
42438
  #clientId;
42439
+ #cacheLookupPolicy;
41815
42440
  /**
41816
42441
  * Creates a new MSAL client instance.
41817
42442
  *
@@ -41821,6 +42446,7 @@ class MsalClient extends PublicClientApplication {
41821
42446
  super(config);
41822
42447
  this.#tenantId = config.auth?.tenantId;
41823
42448
  this.#clientId = config.auth?.clientId;
42449
+ this.#cacheLookupPolicy = config.cacheLookupPolicy;
41824
42450
  }
41825
42451
  /**
41826
42452
  * Tenant identifier for the configured Azure AD tenant.
@@ -41975,7 +42601,11 @@ class MsalClient extends PublicClientApplication {
41975
42601
  if (request.account) {
41976
42602
  try {
41977
42603
  this.getLogger().verbose('Attempting to acquire token silently', request.correlationId || FUSION_CORRELATION_ID);
41978
- return await this.acquireTokenSilent(request);
42604
+ return await this.acquireTokenSilent({
42605
+ // Instance-level policy is the default; request-level cacheLookupPolicy takes precedence
42606
+ cacheLookupPolicy: this.#cacheLookupPolicy,
42607
+ ...request,
42608
+ });
41979
42609
  }
41980
42610
  catch {
41981
42611
  // Silent acquisition failed - fall back to interactive
@@ -42089,7 +42719,7 @@ const createClientLogCallback = (provider, metadata, scope) => {
42089
42719
  };
42090
42720
 
42091
42721
  // Generated by genversion.
42092
- const version$2 = '8.0.4';
42722
+ const version$2 = '9.0.0';
42093
42723
 
42094
42724
  /**
42095
42725
  * Zod schema for telemetry configuration validation.
@@ -42116,6 +42746,10 @@ const MsalConfigSchema = z.object({
42116
42746
  redirectUri: z.string().optional(),
42117
42747
  loginHint: z.string().optional(),
42118
42748
  authCode: z.string().optional(),
42749
+ cacheLookupPolicy: z
42750
+ .custom((val) => typeof val === 'number' &&
42751
+ Object.values(CacheLookupPolicy).includes(val))
42752
+ .optional(),
42119
42753
  version: z.string().transform((x) => String(semver.coerce(x))),
42120
42754
  telemetry: TelemetryConfigSchema,
42121
42755
  });
@@ -42158,6 +42792,8 @@ class MsalConfigurator extends BaseConfigBuilder {
42158
42792
  return telemetry;
42159
42793
  }
42160
42794
  });
42795
+ // Default cache lookup policy to AccessTokenAndRefreshToken to avoid iframe fallback delays
42796
+ this._set('cacheLookupPolicy', async () => CacheLookupPolicy.AccessTokenAndRefreshToken);
42161
42797
  }
42162
42798
  /**
42163
42799
  * Sets the MSAL client configuration for authentication.
@@ -42183,6 +42819,33 @@ class MsalConfigurator extends BaseConfigBuilder {
42183
42819
  this.#msalConfig = config;
42184
42820
  return this;
42185
42821
  }
42822
+ /**
42823
+ * Sets the cache lookup policy used for every silent token acquisition.
42824
+ *
42825
+ * Controls whether MSAL falls back to a hidden iframe when the refresh token
42826
+ * fails. Defaults to `CacheLookupPolicy.AccessTokenAndRefreshToken`, which skips
42827
+ * the iframe step and fails immediately with `InteractionRequiredAuthError` when
42828
+ * the refresh token is revoked — avoiding the ~10–20 s `monitor_window_timeout`
42829
+ * delay caused by MSAL's built-in iframe fallback.
42830
+ *
42831
+ * Set to `CacheLookupPolicy.Default` to restore MSAL's full waterfall:
42832
+ * cache → refresh token → iframe.
42833
+ *
42834
+ * @param policy - Cache lookup policy to apply
42835
+ * @returns The configurator instance for method chaining
42836
+ *
42837
+ * @example
42838
+ * ```typescript
42839
+ * import { CacheLookupPolicy } from '@azure/msal-browser';
42840
+ *
42841
+ * // Restore MSAL's built-in iframe fallback (not recommended for most apps)
42842
+ * configurator.setCacheLookupPolicy(CacheLookupPolicy.Default);
42843
+ * ```
42844
+ */
42845
+ setCacheLookupPolicy(policy) {
42846
+ this._set('cacheLookupPolicy', async () => policy);
42847
+ return this;
42848
+ }
42186
42849
  /**
42187
42850
  * Sets a backend-issued authorization code for token exchange.
42188
42851
  *
@@ -42389,6 +43052,10 @@ class MsalConfigurator extends BaseConfigBuilder {
42389
43052
  },
42390
43053
  };
42391
43054
  }
43055
+ // Apply silent cache lookup policy if configured
43056
+ if (config.cacheLookupPolicy !== undefined) {
43057
+ clientConfig.cacheLookupPolicy = config.cacheLookupPolicy;
43058
+ }
42392
43059
  // Instantiate MSAL client with fully configured options
42393
43060
  config.client = new MsalClient(clientConfig);
42394
43061
  }
@@ -46869,7 +47536,7 @@ async function registerServiceWorker(framework) {
46869
47536
  }
46870
47537
 
46871
47538
  // Generated by genversion.
46872
- const version = '4.0.7';
47539
+ const version = '4.0.9';
46873
47540
 
46874
47541
  // Allow dynamic import without vite
46875
47542
  const importWithoutVite = (path) => import(/* @vite-ignore */ path);