@opensourcekd/ng-common-libs 1.2.2 → 1.2.4

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/README.md CHANGED
@@ -12,6 +12,8 @@ This library features a **dual-layer architecture**:
12
12
  ## 🚀 Features
13
13
 
14
14
  - **Event Bus**: Centralized event communication (framework-agnostic)
15
+ - **EventBusService**: MicroFrontend-ready event bus with replay buffer for cross-app communication
16
+ - **Auth0 Integration**: Complete Auth0 authentication service with token management
15
17
  - **Token Manager**: JWT token management and validation (framework-agnostic)
16
18
  - **Storage Manager**: Type-safe localStorage/sessionStorage wrapper (framework-agnostic)
17
19
  - **Logger**: Configurable logging with multiple levels (framework-agnostic)
@@ -24,6 +26,10 @@ This library features a **dual-layer architecture**:
24
26
  npm install @opensourcekd/ng-common-libs
25
27
  ```
26
28
 
29
+ > **Note:** `mitt` and `@auth0/auth0-spa-js` are bundled with the library. You don't need to install them separately.
30
+ >
31
+ > **Module Federation**: Just configure `@opensourcekd/ng-common-libs` as shared in your webpack config. The bundled dependencies (`mitt`, `@auth0/auth0-spa-js`) will be included automatically, ensuring they're loaded only once across all micro-frontends.
32
+
27
33
  ## 🔧 Usage
28
34
 
29
35
  ### For Angular Projects
@@ -89,6 +95,80 @@ export class AuthService {
89
95
  }
90
96
  ```
91
97
 
98
+ ### Auth0 Authentication
99
+
100
+ Complete Auth0 integration with automatic token management and event emission:
101
+
102
+ ```typescript
103
+ import { Component, inject } from '@angular/core';
104
+ import { AuthService, configureAuth0 } from '@opensourcekd/ng-common-libs';
105
+
106
+ // Configure Auth0 in your app.config.ts
107
+ configureAuth0({
108
+ domain: 'your-domain.auth0.com',
109
+ clientId: 'your-client-id',
110
+ audience: 'https://your-api.com',
111
+ });
112
+
113
+ @Component({
114
+ selector: 'app-login',
115
+ template: `
116
+ <button (click)="login()">Login with Auth0</button>
117
+ <button (click)="logout()" *ngIf="user">Logout</button>
118
+ <div *ngIf="user">Welcome, {{ user.name }}!</div>
119
+ `
120
+ })
121
+ export class LoginComponent {
122
+ private authService = inject(AuthService);
123
+ user = this.authService.getUser();
124
+
125
+ async login() {
126
+ await this.authService.login();
127
+ }
128
+
129
+ async logout() {
130
+ await this.authService.logout();
131
+ }
132
+ }
133
+ ```
134
+
135
+ See the [Auth0 Service Usage Guide](./docs/AUTH_SERVICE_USAGE.md) for complete integration instructions.
136
+
137
+ ### EventBusService
138
+
139
+ Cross-application event communication for MicroFrontend architectures:
140
+
141
+ ```typescript
142
+ import { Component, OnInit, inject } from '@angular/core';
143
+ import { EventBusService } from '@opensourcekd/ng-common-libs';
144
+
145
+ @Component({
146
+ selector: 'app-event-example',
147
+ template: `<button (click)="sendEvent()">Send Event</button>`
148
+ })
149
+ export class EventExampleComponent implements OnInit {
150
+ private eventBus = inject(EventBusService);
151
+
152
+ ngOnInit() {
153
+ // Subscribe to all events
154
+ this.eventBus.onePlusNEvents.subscribe(event => {
155
+ console.log('Event received:', event);
156
+ });
157
+ }
158
+
159
+ sendEvent() {
160
+ // Send structured event
161
+ this.eventBus.sendEvent(JSON.stringify({
162
+ type: 'user:action',
163
+ payload: { userId: '123' },
164
+ timestamp: new Date().toISOString()
165
+ }));
166
+ }
167
+ }
168
+ ```
169
+
170
+ See the [EventBus Service Usage Guide](./docs/EVENT_BUS_USAGE.md) for advanced patterns and MicroFrontend examples.
171
+
92
172
  #### Auth Guard
93
173
 
94
174
  Protect routes with authentication guards:
@@ -366,6 +446,8 @@ export default {
366
446
 
367
447
  - **[Usage Guide](./docs/USAGE.md)** - Complete usage examples for all utilities
368
448
  - **[API Reference](./docs/API.md)** - Detailed API documentation
449
+ - **[Auth0 Service Usage](./docs/AUTH_SERVICE_USAGE.md)** - Complete Auth0 authentication integration guide
450
+ - **[EventBus Service Usage](./docs/EVENT_BUS_USAGE.md)** - Cross-application event communication guide
369
451
  - **[Deployment Guide](./docs/DEPLOYMENT.md)** - Publishing, versioning, and consumption
370
452
  - **[Microapp Triggering Guide](./docs/MICROAPP_TRIGGERING.md)** - Automatic build triggering for consuming microapps
371
453
  - **[Module Federation Guide](./docs/MODULE_FEDERATION.md)** - Runtime sharing with Module Federation