@opensourcekd/ng-common-libs 1.2.6 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -82,8 +82,24 @@ declare const APP_CONFIG: {
82
82
  * This service is designed for MicroFrontend architectures where different apps need to communicate
83
83
  * The ReplaySubject keeps last 100 events in memory for late subscribers
84
84
  *
85
+ * **IMPORTANT for Module Federation / MicroFrontends:**
86
+ * This service uses a module-level singleton to ensure ONE instance across all MFEs and shell.
87
+ * Before using `inject(EventBusService)` in components, you must provide it at application level:
88
+ *
85
89
  * @example
86
90
  * ```typescript
91
+ * // In app.config.ts (standalone) or app.module.ts (NgModule)
92
+ * import { EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
93
+ *
94
+ * export const appConfig: ApplicationConfig = {
95
+ * providers: [
96
+ * { provide: EventBusService, useFactory: getEventBusService }
97
+ * ]
98
+ * };
99
+ * ```
100
+ *
101
+ * Then use in components:
102
+ * ```typescript
87
103
  * import { Component, inject, OnInit } from '@angular/core';
88
104
  * import { EventBusService } from '@opensourcekd/ng-common-libs';
89
105
  *
@@ -148,6 +164,25 @@ declare class EventBusService {
148
164
  */
149
165
  sendEvent(s: string): void;
150
166
  }
167
+ /**
168
+ * Factory function to get the singleton EventBusService instance
169
+ * Use this in your application providers to ensure singleton behavior across MFEs
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // In app.config.ts or app.module.ts
174
+ * import { EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
175
+ *
176
+ * export const appConfig: ApplicationConfig = {
177
+ * providers: [
178
+ * { provide: EventBusService, useFactory: getEventBusService }
179
+ * ]
180
+ * };
181
+ * ```
182
+ *
183
+ * @returns The singleton EventBusService instance
184
+ */
185
+ declare function getEventBusService(): EventBusService;
151
186
 
152
187
  /**
153
188
  * User information from ID token
@@ -189,6 +224,23 @@ interface UserData {
189
224
  *
190
225
  * Configuration is centralized in config/auth.config.ts for easy management
191
226
  *
227
+ * **IMPORTANT for Module Federation / MicroFrontends:**
228
+ * This service uses a module-level singleton to ensure ONE instance across all MFEs and shell.
229
+ * Before using `inject(AuthService)` in components, you must provide it at application level:
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * // In app.config.ts (standalone) or app.module.ts (NgModule)
234
+ * import { AuthService, getAuthService, EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
235
+ *
236
+ * export const appConfig: ApplicationConfig = {
237
+ * providers: [
238
+ * { provide: EventBusService, useFactory: getEventBusService },
239
+ * { provide: AuthService, useFactory: getAuthService }
240
+ * ]
241
+ * };
242
+ * ```
243
+ *
192
244
  * NOTE: All navigation logic using setTimeout is commented out as per requirements.
193
245
  * To enable navigation after auth operations, uncomment the marked sections in consuming components.
194
246
  */
@@ -346,6 +398,28 @@ declare class AuthService {
346
398
  */
347
399
  private emitAuthEvent;
348
400
  }
401
+ /**
402
+ * Factory function to get the singleton AuthService instance
403
+ * Use this in your application providers to ensure singleton behavior across MFEs
404
+ *
405
+ * Lazy initialization ensures Auth0 can be configured before service creation
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * // In app.config.ts or app.module.ts
410
+ * import { AuthService, getAuthService, EventBusService, getEventBusService } from '@opensourcekd/ng-common-libs';
411
+ *
412
+ * export const appConfig: ApplicationConfig = {
413
+ * providers: [
414
+ * { provide: EventBusService, useFactory: getEventBusService },
415
+ * { provide: AuthService, useFactory: getAuthService }
416
+ * ]
417
+ * };
418
+ * ```
419
+ *
420
+ * @returns The singleton AuthService instance
421
+ */
422
+ declare function getAuthService(): AuthService;
349
423
 
350
424
  /**
351
425
  * Auth0 Configuration
@@ -357,6 +431,10 @@ declare class AuthService {
357
431
  /**
358
432
  * Auth0 client configuration
359
433
  * Override these values in your consuming application by setting them before importing AuthService
434
+ *
435
+ * Note: redirectUri defaults to window.location.origin (base URL without path).
436
+ * Auth0 will redirect back to this URL after authentication.
437
+ * You can override this to a specific callback URL (e.g., '/auth-callback') using configureAuth0().
360
438
  */
361
439
  declare const AUTH0_CONFIG: {
362
440
  domain: string;
@@ -407,21 +485,33 @@ declare function setStorageItem(key: string, value: string, storageType?: 'local
407
485
  */
408
486
  declare function removeStorageItem(key: string, storageType?: 'localStorage' | 'sessionStorage'): void;
409
487
  /**
410
- * Configure Auth0 settings
411
- * Call this function in your consuming application before using AuthService
488
+ * Configure Auth0 settings (OPTIONAL)
489
+ * Call this function in your consuming application to override default Auth0 configuration.
490
+ * Only the values you provide will be overridden; all other defaults remain unchanged.
491
+ *
492
+ * Note: This function is optional. If not called, default values will be used.
493
+ *
494
+ * @param config - Partial Auth0 configuration object with values to override
412
495
  *
413
496
  * @example
414
497
  * ```typescript
415
498
  * import { configureAuth0 } from '@opensourcekd/ng-common-libs';
416
499
  *
500
+ * // Only override specific values - others keep their defaults
417
501
  * configureAuth0({
418
502
  * domain: 'your-domain.auth0.com',
419
503
  * clientId: 'your-client-id',
420
504
  * audience: 'https://your-api.com'
505
+ * // redirectUri, logoutUri, scope, etc. will use defaults
506
+ * });
507
+ *
508
+ * // Or override just redirectUri to use a specific callback page
509
+ * configureAuth0({
510
+ * redirectUri: window.location.origin + '/auth-callback'
421
511
  * });
422
512
  * ```
423
513
  */
424
514
  declare function configureAuth0(config: Partial<typeof AUTH0_CONFIG>): void;
425
515
 
426
- export { APP_CONFIG, AUTH0_CONFIG, AuthService, EventBus, EventBusService, STORAGE_CONFIG, STORAGE_KEYS, configureAuth0, getStorageItem, removeStorageItem, setStorageItem };
516
+ export { APP_CONFIG, AUTH0_CONFIG, AuthService, EventBus, EventBusService, STORAGE_CONFIG, STORAGE_KEYS, configureAuth0, getAuthService, getEventBusService, getStorageItem, removeStorageItem, setStorageItem };
427
517
  export type { EventPayload, UserData, UserInfo };