@opensourcekd/ng-common-libs 1.2.5 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,7 @@ This library features a **dual-layer architecture**:
11
11
 
12
12
  ## 🚀 Features
13
13
 
14
+ - **APP_CONFIG**: Framework-agnostic configuration utility for all environment variables (Auth0, API URLs)
14
15
  - **EventBusService**: MicroFrontend-ready event bus with replay buffer for cross-app communication
15
16
  - **Auth0 Integration**: Complete Auth0 authentication service with token management
16
17
 
@@ -26,6 +27,26 @@ npm install @opensourcekd/ng-common-libs
26
27
 
27
28
  ## 🔧 Usage
28
29
 
30
+ ### Configuration (Framework-Agnostic)
31
+
32
+ The library provides a framework-agnostic configuration utility with **statically configured values** from GitHub repository variables:
33
+
34
+ ```typescript
35
+ // Import from /core for framework-agnostic usage
36
+ import { APP_CONFIG } from '@opensourcekd/ng-common-libs/core';
37
+
38
+ // Access pre-configured values anywhere in your app
39
+ console.log(APP_CONFIG.apiUrl); // Configured during build from GitHub vars
40
+ console.log(APP_CONFIG.auth0Domain); // Configured during build from GitHub vars
41
+ console.log(APP_CONFIG.auth0ClientId); // Configured during build from GitHub vars
42
+ ```
43
+
44
+ **Key Features:**
45
+ - Values are **statically baked** into the library during build time from GitHub repository variables
46
+ - No runtime configuration needed - values are available immediately
47
+ - Can be used across any framework: Angular, React, Vue, Svelte, vanilla JS
48
+ - Perfect for MicroFrontends (MFEs) and shell applications
49
+
29
50
  ### Auth0 Authentication
30
51
 
31
52
  Complete Auth0 integration with automatic token management and event emission:
@@ -33,12 +54,13 @@ Complete Auth0 integration with automatic token management and event emission:
33
54
  ```typescript
34
55
  import { Component, inject } from '@angular/core';
35
56
  import { AuthService, configureAuth0 } from '@opensourcekd/ng-common-libs';
57
+ import { APP_CONFIG } from '@opensourcekd/ng-common-libs/core';
36
58
 
37
- // Configure Auth0 in your app.config.ts
59
+ // Use pre-configured values from APP_CONFIG
38
60
  configureAuth0({
39
- domain: 'your-domain.auth0.com',
40
- clientId: 'your-client-id',
41
- audience: 'https://your-api.com',
61
+ domain: APP_CONFIG.auth0Domain,
62
+ clientId: APP_CONFIG.auth0ClientId,
63
+ audience: APP_CONFIG.apiUrl,
42
64
  });
43
65
 
44
66
  @Component({
@@ -181,16 +203,30 @@ export default {
181
203
 
182
204
  ## 📝 API Documentation
183
205
 
206
+ ### Core Configuration (Framework-Agnostic)
207
+
208
+ - `APP_CONFIG` - Read-only application configuration object with values statically configured during build time:
209
+ - `auth0Domain: string` - Auth0 tenant domain (from GitHub var `AUTH0_DOMAIN`)
210
+ - `auth0ClientId: string` - Auth0 client ID (from GitHub var `AUTH0_CLIENT_ID`)
211
+ - `apiUrl: string` - API base URL (from GitHub var `API_URL`)
212
+
213
+ ### Angular Configuration
214
+
215
+ - `configureAuth0(config: Partial<AUTH0_CONFIG>): void` - Configure Auth0 settings (domain, clientId, etc.)
216
+ - `AUTH0_CONFIG` - Auth0 configuration object (domain, clientId, redirectUri, etc.)
217
+
184
218
  ### AuthService
185
219
 
186
- - `login(options?: RedirectLoginOptions): Promise<void>` - Initiate Auth0 login
187
- - `logout(options?: LogoutOptions): Promise<void>` - Logout and clear session
188
- - `handleCallback(): Promise<{ success: boolean, appState?: any }>` - Handle Auth0 callback
189
- - `getToken(): Promise<string | null>` - Get access token asynchronously
190
- - `getTokenSync(): string | null` - Get cached access token synchronously
191
- - `getUser(): Signal<UserInfo | null>` - Get user information as signal
192
- - `isAuthenticated(): Signal<boolean>` - Check authentication status
193
- - `isLoading(): Signal<boolean>` - Check if authentication is loading
220
+ - `login(user?: string, options?: { invitation?: string; organization?: string }): Promise<void>` - Initiate Auth0 login with optional user identifier and organization invitation parameters
221
+ - `logout(): Promise<void>` - Logout and clear session
222
+ - `handleCallback(): Promise<{ success: boolean, appState?: any }>` - Handle Auth0 callback and return success status with preserved appState
223
+ - `getToken(): Promise<string | null>` - Get access token asynchronously (checks storage first, then Auth0)
224
+ - `getTokenSync(): string | null` - Get cached access token synchronously (storage only)
225
+ - `getUser(): UserInfo | null` - Get current user information
226
+ - `getUserData(): UserData | null` - Get simplified user data with role and organization extraction
227
+ - `isAuthenticated(): Promise<boolean>` - Check authentication status asynchronously (verifies with Auth0)
228
+ - `isAuthenticatedSync(): boolean` - Check authentication status synchronously (storage only)
229
+ - `user$: Observable<UserInfo | null>` - Observable stream of user changes
194
230
 
195
231
  ### EventBusService
196
232