@opensourcekd/ng-common-libs 2.0.2 → 2.0.3
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 +47 -58
- package/dist/index.cjs +113 -498
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +123 -280
- package/dist/index.mjs +111 -496
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
# ng-common-libs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pure TypeScript library with Auth0 authentication service and framework-agnostic event bus.
|
|
4
4
|
|
|
5
5
|
## 🎯 Simple Architecture
|
|
6
6
|
|
|
7
|
-
**One import path. Everything you need.**
|
|
7
|
+
**One import path. Everything you need. Framework-agnostic.**
|
|
8
8
|
|
|
9
9
|
All services, utilities, and types are exported from a single package:
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
import {
|
|
13
13
|
AuthService,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getApiUrl,
|
|
18
|
-
UserInfo,
|
|
19
|
-
EventBus
|
|
14
|
+
EventBus,
|
|
15
|
+
APP_CONFIG,
|
|
16
|
+
UserInfo
|
|
20
17
|
} from '@opensourcekd/ng-common-libs';
|
|
21
18
|
```
|
|
22
19
|
|
|
@@ -24,11 +21,11 @@ import {
|
|
|
24
21
|
|
|
25
22
|
## 🚀 Features
|
|
26
23
|
|
|
27
|
-
- **AuthService**: Complete Auth0 authentication with token management
|
|
28
|
-
- **
|
|
24
|
+
- **AuthService**: Complete Auth0 authentication with token management (Pure TypeScript - no Angular dependency)
|
|
25
|
+
- **EventBus**: Framework-agnostic event bus using RxJS
|
|
26
|
+
- **Works with any framework**: Angular, React, Vue, Svelte, vanilla JS
|
|
29
27
|
- **Module Federation Support**: Singleton pattern works across shell + MFEs
|
|
30
|
-
- **
|
|
31
|
-
- **Framework-Agnostic Core**: EventBus can be used in React, Vue, or vanilla JS
|
|
28
|
+
- **Zero Framework Lock-in**: Core services are pure TypeScript classes
|
|
32
29
|
|
|
33
30
|
## 📦 Installation
|
|
34
31
|
|
|
@@ -40,46 +37,31 @@ npm install @opensourcekd/ng-common-libs
|
|
|
40
37
|
|
|
41
38
|
## 🔧 Quick Start
|
|
42
39
|
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
**In your shell app AND each MFE's `app.config.ts`:**
|
|
40
|
+
### Pure TypeScript Usage (Framework-Agnostic)
|
|
46
41
|
|
|
47
42
|
```typescript
|
|
48
|
-
import {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export const appConfig: ApplicationConfig = {
|
|
59
|
-
providers: [
|
|
60
|
-
// Factory functions ensure singleton across all MFEs
|
|
61
|
-
{ provide: EventBusService, useFactory: getEventBusService },
|
|
62
|
-
{ provide: AuthService, useFactory: getAuthService },
|
|
63
|
-
]
|
|
43
|
+
import { AuthService, EventBus } from '@opensourcekd/ng-common-libs';
|
|
44
|
+
|
|
45
|
+
// Create instances
|
|
46
|
+
const eventBus = new EventBus();
|
|
47
|
+
const authConfig = {
|
|
48
|
+
domain: 'your-domain.auth0.com',
|
|
49
|
+
clientId: 'your-client-id',
|
|
50
|
+
redirectUri: window.location.origin,
|
|
51
|
+
logoutUri: window.location.origin,
|
|
52
|
+
scope: 'openid profile email'
|
|
64
53
|
};
|
|
65
|
-
|
|
54
|
+
const authService = new AuthService(authConfig, eventBus);
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
// Use the service
|
|
57
|
+
await authService.login();
|
|
58
|
+
const user = authService.getUser();
|
|
59
|
+
const token = await authService.getToken();
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import { Component, inject } from '@angular/core';
|
|
75
|
-
import { AuthService, EventBusService } from '@opensourcekd/ng-common-libs';
|
|
76
|
-
|
|
77
|
-
export class MyComponent {
|
|
78
|
-
private authService = inject(AuthService);
|
|
79
|
-
private eventBus = inject(EventBusService);
|
|
80
|
-
|
|
81
|
-
login() { this.authService.login(); }
|
|
82
|
-
}
|
|
61
|
+
// Subscribe to events
|
|
62
|
+
eventBus.on('auth:login_success').subscribe(data => {
|
|
63
|
+
console.log('User logged in:', data);
|
|
64
|
+
});
|
|
83
65
|
```
|
|
84
66
|
|
|
85
67
|
### API URL Access
|
|
@@ -87,10 +69,10 @@ export class MyComponent {
|
|
|
87
69
|
**No configuration needed** - API URL is automatically available:
|
|
88
70
|
|
|
89
71
|
```typescript
|
|
90
|
-
import {
|
|
72
|
+
import { APP_CONFIG } from '@opensourcekd/ng-common-libs';
|
|
91
73
|
|
|
92
74
|
// API URL is baked into the library during build from GitHub repository variables
|
|
93
|
-
const apiUrl =
|
|
75
|
+
const apiUrl = APP_CONFIG.apiUrl;
|
|
94
76
|
const endpoint = `${apiUrl}/users`;
|
|
95
77
|
```
|
|
96
78
|
|
|
@@ -111,22 +93,29 @@ Everything you need from one import:
|
|
|
111
93
|
import {
|
|
112
94
|
// Services
|
|
113
95
|
AuthService,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// Factory Functions
|
|
117
|
-
getAuthService,
|
|
118
|
-
getEventBusService,
|
|
96
|
+
EventBus,
|
|
119
97
|
|
|
120
|
-
//
|
|
121
|
-
|
|
98
|
+
// Configuration
|
|
99
|
+
APP_CONFIG,
|
|
100
|
+
AUTH0_CONFIG,
|
|
101
|
+
STORAGE_CONFIG,
|
|
102
|
+
STORAGE_KEYS,
|
|
122
103
|
|
|
123
|
-
//
|
|
124
|
-
|
|
104
|
+
// Utilities
|
|
105
|
+
getStorageItem,
|
|
106
|
+
setStorageItem,
|
|
107
|
+
removeStorageItem,
|
|
125
108
|
|
|
126
109
|
// Types & Interfaces
|
|
127
110
|
UserInfo,
|
|
128
111
|
UserData,
|
|
129
112
|
EventPayload,
|
|
113
|
+
Auth0Config,
|
|
114
|
+
StorageConfig,
|
|
115
|
+
StorageKeys,
|
|
116
|
+
AppState,
|
|
117
|
+
AuthorizationParams,
|
|
118
|
+
CallbackResult,
|
|
130
119
|
} from '@opensourcekd/ng-common-libs';
|
|
131
120
|
```
|
|
132
121
|
|