dinocollab-core 2.0.3 → 2.0.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.
Files changed (75) hide show
  1. package/dist/api-context.d.ts +2 -0
  2. package/dist/api-context.js +2 -0
  3. package/dist/api-context.mjs +2 -0
  4. package/dist/components.d.ts +2 -0
  5. package/dist/components.js +2 -0
  6. package/dist/components.mjs +2 -0
  7. package/dist/data-view.d.ts +2 -0
  8. package/dist/data-view.js +2 -0
  9. package/dist/data-view.mjs +2 -0
  10. package/dist/form.d.ts +2 -0
  11. package/dist/form.js +2 -0
  12. package/dist/form.mjs +2 -0
  13. package/dist/hooks.d.ts +2 -0
  14. package/dist/hooks.js +2 -0
  15. package/dist/hooks.mjs +2 -0
  16. package/dist/http-service.d.ts +2 -0
  17. package/dist/http-service.js +2 -0
  18. package/dist/http-service.mjs +2 -0
  19. package/dist/mfe-shared/auth.js.map +1 -1
  20. package/dist/mfe-shared/auth.ssr.js.map +1 -1
  21. package/dist/mfe-shared/auth.types.js.map +1 -1
  22. package/dist/mfe-shared/hydration-helper.js +1 -1
  23. package/dist/mfe-shared/hydration-helper.js.map +1 -1
  24. package/dist/mfe-shared/index.js +1 -1
  25. package/dist/mfe-shared/mfe-bridge.js.map +1 -1
  26. package/dist/mfe-shared.d.ts +2 -0
  27. package/dist/mfe-shared.js +2 -0
  28. package/dist/mfe-shared.mjs +2 -0
  29. package/dist/redux.d.ts +2 -0
  30. package/dist/redux.js +2 -0
  31. package/dist/redux.mjs +2 -0
  32. package/dist/table-grid.d.ts +2 -0
  33. package/dist/table-grid.js +2 -0
  34. package/dist/table-grid.mjs +2 -0
  35. package/dist/table.d.ts +2 -0
  36. package/dist/table.js +2 -0
  37. package/dist/table.mjs +2 -0
  38. package/dist/types/mfe-shared/auth.d.ts +13 -8
  39. package/dist/types/mfe-shared/auth.ssr.d.ts +3 -3
  40. package/dist/types/mfe-shared/auth.types.d.ts +4 -4
  41. package/dist/types/mfe-shared/cart.debug.d.ts +2 -2
  42. package/dist/types/mfe-shared/hydration-helper.d.ts +4 -4
  43. package/dist/types/mfe-shared/index.d.ts +6 -4
  44. package/dist/types/mfe-shared/mfe-bridge.d.ts +4 -4
  45. package/dist/types/mfe-shared/types.d.ts +4 -4
  46. package/dist/utils.d.ts +2 -0
  47. package/dist/utils.js +2 -0
  48. package/dist/utils.mjs +2 -0
  49. package/package.json +90 -8
  50. package/dist/mfe-auth/auth-enums.js +0 -2
  51. package/dist/mfe-auth/auth-enums.js.map +0 -1
  52. package/dist/mfe-auth/auth-mfe-manager.js +0 -2
  53. package/dist/mfe-auth/auth-mfe-manager.js.map +0 -1
  54. package/dist/mfe-auth/auth-mfe-provider.js +0 -2
  55. package/dist/mfe-auth/auth-mfe-provider.js.map +0 -1
  56. package/dist/mfe-auth/auth-types.js +0 -2
  57. package/dist/mfe-auth/auth-types.js.map +0 -1
  58. package/dist/mfe-auth/index.js +0 -2
  59. package/dist/mfe-auth/index.js.map +0 -1
  60. package/dist/mfe-auth/micro-frontend-auth-hooks.js +0 -2
  61. package/dist/mfe-auth/micro-frontend-auth-hooks.js.map +0 -1
  62. package/dist/types/mfe-auth/auth-enums.d.ts +0 -40
  63. package/dist/types/mfe-auth/auth-mfe-manager.d.ts +0 -68
  64. package/dist/types/mfe-auth/auth-mfe-provider.d.ts +0 -19
  65. package/dist/types/mfe-auth/auth-types.d.ts +0 -33
  66. package/dist/types/mfe-auth/index.d.ts +0 -6
  67. package/dist/types/mfe-auth/micro-frontend-auth-hooks.d.ts +0 -164
  68. package/dist/types/mfe-navigate/index.d.ts +0 -2
  69. package/dist/types/mfe-navigate/mfe-navigate.debug.d.ts +0 -4
  70. package/dist/types/mfe-navigate/mfe-navigate.remote.d.ts +0 -11
  71. package/dist/types/mfe-navigate/nextjs/index.d.ts +0 -1
  72. package/dist/types/mfe-navigate/nextjs/provider.d.ts +0 -2
  73. package/dist/types/mfe-navigate/react/index.d.ts +0 -1
  74. package/dist/types/mfe-navigate/react/provider.d.ts +0 -3
  75. package/dist/types/mfe-navigate/types.d.ts +0 -13
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "dinocollab-core",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/types/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "scripts": {
10
- "build": "npx rimraf dist && rollup -c",
10
+ "build": "npx rimraf dist && rollup -c && node create-proxy-files.js",
11
11
  "build:watch": "rollup -c -w",
12
- "build:analyze": "npx rimraf dist && rollup -c",
12
+ "build:analyze": "npx rimraf dist && rollup -c && node create-proxy-files.js",
13
13
  "calc-size": "node calc-build-size.js"
14
14
  },
15
15
  "bin": {
@@ -21,37 +21,73 @@
21
21
  ],
22
22
  "typesVersions": {
23
23
  "*": {
24
+ ".": [
25
+ "./dist/types/index.d.ts"
26
+ ],
24
27
  "api-context": [
28
+ "./dist/api-context.d.ts"
29
+ ],
30
+ "./api-context": [
25
31
  "./dist/types/api-context/index.d.ts"
26
32
  ],
27
33
  "components": [
34
+ "./dist/components.d.ts"
35
+ ],
36
+ "./components": [
28
37
  "./dist/types/components/index.d.ts"
29
38
  ],
30
39
  "data-view": [
40
+ "./dist/data-view.d.ts"
41
+ ],
42
+ "./data-view": [
31
43
  "./dist/types/data-view/index.d.ts"
32
44
  ],
33
45
  "form": [
46
+ "./dist/form.d.ts"
47
+ ],
48
+ "./form": [
34
49
  "./dist/types/form/index.d.ts"
35
50
  ],
36
51
  "hooks": [
52
+ "./dist/hooks.d.ts"
53
+ ],
54
+ "./hooks": [
37
55
  "./dist/types/hooks/index.d.ts"
38
56
  ],
39
57
  "http-service": [
58
+ "./dist/http-service.d.ts"
59
+ ],
60
+ "./http-service": [
40
61
  "./dist/types/http-service/index.d.ts"
41
62
  ],
42
63
  "mfe-shared": [
64
+ "./dist/mfe-shared.d.ts"
65
+ ],
66
+ "./mfe-shared": [
43
67
  "./dist/types/mfe-shared/index.d.ts"
44
68
  ],
45
69
  "redux": [
70
+ "./dist/redux.d.ts"
71
+ ],
72
+ "./redux": [
46
73
  "./dist/types/redux/index.d.ts"
47
74
  ],
48
75
  "table": [
76
+ "./dist/table.d.ts"
77
+ ],
78
+ "./table": [
49
79
  "./dist/types/table/index.d.ts"
50
80
  ],
51
81
  "table-grid": [
82
+ "./dist/table-grid.d.ts"
83
+ ],
84
+ "./table-grid": [
52
85
  "./dist/types/table-grid/index.d.ts"
53
86
  ],
54
87
  "utils": [
88
+ "./dist/utils.d.ts"
89
+ ],
90
+ "./utils": [
55
91
  "./dist/types/utils/index.d.ts"
56
92
  ]
57
93
  }
@@ -59,52 +95,98 @@
59
95
  "exports": {
60
96
  ".": {
61
97
  "import": "./dist/index.js",
98
+ "require": "./dist/index.js",
62
99
  "types": "./dist/types/index.d.ts"
63
100
  },
64
101
  "./api-context": {
65
102
  "import": "./dist/api-context/index.js",
103
+ "require": "./dist/api-context/index.js",
66
104
  "types": "./dist/types/api-context/index.d.ts"
67
105
  },
106
+ "./api-context.js": "./dist/api-context.js",
107
+ "./api-context.mjs": "./dist/api-context.mjs",
108
+ "./api-context.d.ts": "./dist/api-context.d.ts",
68
109
  "./components": {
69
110
  "import": "./dist/components/index.js",
111
+ "require": "./dist/components/index.js",
70
112
  "types": "./dist/types/components/index.d.ts"
71
113
  },
114
+ "./components.js": "./dist/components.js",
115
+ "./components.mjs": "./dist/components.mjs",
116
+ "./components.d.ts": "./dist/components.d.ts",
72
117
  "./data-view": {
73
118
  "import": "./dist/data-view/index.js",
119
+ "require": "./dist/data-view/index.js",
74
120
  "types": "./dist/types/data-view/index.d.ts"
75
121
  },
122
+ "./data-view.js": "./dist/data-view.js",
123
+ "./data-view.mjs": "./dist/data-view.mjs",
124
+ "./data-view.d.ts": "./dist/data-view.d.ts",
76
125
  "./form": {
77
126
  "import": "./dist/form/index.js",
127
+ "require": "./dist/form/index.js",
78
128
  "types": "./dist/types/form/index.d.ts"
79
129
  },
130
+ "./form.js": "./dist/form.js",
131
+ "./form.mjs": "./dist/form.mjs",
132
+ "./form.d.ts": "./dist/form.d.ts",
80
133
  "./hooks": {
81
134
  "import": "./dist/hooks/index.js",
135
+ "require": "./dist/hooks/index.js",
82
136
  "types": "./dist/types/hooks/index.d.ts"
83
137
  },
138
+ "./hooks.js": "./dist/hooks.js",
139
+ "./hooks.mjs": "./dist/hooks.mjs",
140
+ "./hooks.d.ts": "./dist/hooks.d.ts",
84
141
  "./http-service": {
85
142
  "import": "./dist/http-service/index.js",
143
+ "require": "./dist/http-service/index.js",
86
144
  "types": "./dist/types/http-service/index.d.ts"
87
145
  },
146
+ "./http-service.js": "./dist/http-service.js",
147
+ "./http-service.mjs": "./dist/http-service.mjs",
148
+ "./http-service.d.ts": "./dist/http-service.d.ts",
88
149
  "./mfe-shared": {
89
150
  "import": "./dist/mfe-shared/index.js",
151
+ "require": "./dist/mfe-shared/index.js",
90
152
  "types": "./dist/types/mfe-shared/index.d.ts"
91
153
  },
92
- "./utils": {
93
- "import": "./dist/utils/index.js",
94
- "types": "./dist/types/utils/index.d.ts"
95
- },
154
+ "./mfe-shared.js": "./dist/mfe-shared.js",
155
+ "./mfe-shared.mjs": "./dist/mfe-shared.mjs",
156
+ "./mfe-shared.d.ts": "./dist/mfe-shared.d.ts",
96
157
  "./redux": {
97
158
  "import": "./dist/redux/index.js",
159
+ "require": "./dist/redux/index.js",
98
160
  "types": "./dist/types/redux/index.d.ts"
99
161
  },
162
+ "./redux.js": "./dist/redux.js",
163
+ "./redux.mjs": "./dist/redux.mjs",
164
+ "./redux.d.ts": "./dist/redux.d.ts",
100
165
  "./table": {
101
166
  "import": "./dist/table/index.js",
167
+ "require": "./dist/table/index.js",
102
168
  "types": "./dist/types/table/index.d.ts"
103
169
  },
170
+ "./table.js": "./dist/table.js",
171
+ "./table.mjs": "./dist/table.mjs",
172
+ "./table.d.ts": "./dist/table.d.ts",
104
173
  "./table-grid": {
105
174
  "import": "./dist/table-grid/index.js",
175
+ "require": "./dist/table-grid/index.js",
106
176
  "types": "./dist/types/table-grid/index.d.ts"
107
- }
177
+ },
178
+ "./table-grid.js": "./dist/table-grid.js",
179
+ "./table-grid.mjs": "./dist/table-grid.mjs",
180
+ "./table-grid.d.ts": "./dist/table-grid.d.ts",
181
+ "./utils": {
182
+ "import": "./dist/utils/index.js",
183
+ "require": "./dist/utils/index.js",
184
+ "types": "./dist/types/utils/index.d.ts"
185
+ },
186
+ "./utils.js": "./dist/utils.js",
187
+ "./utils.mjs": "./dist/utils.mjs",
188
+ "./utils.d.ts": "./dist/utils.d.ts",
189
+ "./package.json": "./package.json"
108
190
  },
109
191
  "keywords": [],
110
192
  "author": "@dinocollab",
@@ -1,2 +0,0 @@
1
- var E,A;!function(E){E.UNAUTHENTICATED="UNAUTHENTICATED",E.AUTHENTICATED="AUTHENTICATED",E.AUTHENTICATING="AUTHENTICATING",E.LOADING="LOADING",E.ERROR="ERROR"}(E||(E={})),function(E){E.DASHBOARD="DASHBOARD",E.PROFILE="PROFILE",E.SETTINGS="SETTINGS",E.MEDIA_STORE="MEDIA_STORE",E.APP_HEADER="APP_HEADER",E.APP_FOOTER="APP_FOOTER",E.VIDEO_GROUP="VIDEO_GROUP",E.TRACK_GROUP="TRACK_GROUP",E.GENERIC="GENERIC"}(A||(A={}));export{E as AuthStatus,A as MicroFrontendType};
2
- //# sourceMappingURL=auth-enums.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-enums.js","sources":["../../src/mfe-auth/auth-enums.ts"],"sourcesContent":["/**\r\n * Authentication Status Enumeration\r\n * Defines possible states of user authentication\r\n */\r\nexport enum AuthStatus {\r\n /** User is not authenticated */\r\n UNAUTHENTICATED = 'UNAUTHENTICATED',\r\n\r\n /** User is successfully authenticated */\r\n AUTHENTICATED = 'AUTHENTICATED',\r\n\r\n /** Authentication process is in progress */\r\n AUTHENTICATING = 'AUTHENTICATING',\r\n\r\n /** Loading authentication state or user data */\r\n LOADING = 'LOADING',\r\n\r\n /** Authentication error occurred */\r\n ERROR = 'ERROR'\r\n}\r\n\r\n/**\r\n * Micro Frontend Type Enumeration\r\n * Identifies different types of micro frontend components\r\n */\r\nexport enum MicroFrontendType {\r\n /** Main dashboard component */\r\n DASHBOARD = 'DASHBOARD',\r\n\r\n /** User profile component */\r\n PROFILE = 'PROFILE',\r\n\r\n /** Settings and configuration component */\r\n SETTINGS = 'SETTINGS',\r\n\r\n /** Media store and gallery component */\r\n MEDIA_STORE = 'MEDIA_STORE',\r\n\r\n /** Application header component */\r\n APP_HEADER = 'APP_HEADER',\r\n\r\n /** Application footer component */\r\n APP_FOOTER = 'APP_FOOTER',\r\n\r\n /** Video player and gallery component */\r\n VIDEO_GROUP = 'VIDEO_GROUP',\r\n\r\n /** Audio track and playlist component */\r\n TRACK_GROUP = 'TRACK_GROUP',\r\n\r\n /** Generic or custom micro frontend component */\r\n GENERIC = 'GENERIC'\r\n}\r\n"],"names":["AuthStatus","MicroFrontendType"],"mappings":"IAIYA,EAqBAC,GArBZ,SAAYD,GAEVA,EAAA,gBAAA,kBAGAA,EAAA,cAAA,gBAGAA,EAAA,eAAA,iBAGAA,EAAA,QAAA,UAGAA,EAAA,MAAA,OACD,CAfD,CAAYA,IAAAA,EAeX,CAAA,IAMD,SAAYC,GAEVA,EAAA,UAAA,YAGAA,EAAA,QAAA,UAGAA,EAAA,SAAA,WAGAA,EAAA,YAAA,cAGAA,EAAA,WAAA,aAGAA,EAAA,WAAA,aAGAA,EAAA,YAAA,cAGAA,EAAA,YAAA,cAGAA,EAAA,QAAA,SACD,CA3BD,CAAYA,IAAAA,EA2BX,CAAA"}
@@ -1,2 +0,0 @@
1
- import{createClass as t,objectSpread2 as e,classCallCheck as n,defineProperty as i}from"../_virtual/_rollupPluginBabelHelpers.js";import{defaultAuthData as a}from"./auth-types.js";var s=function(){function s(){n(this,s),i(this,"authData",a),i(this,"listeners",new Map),i(this,"isInitialized",!1),this.initializeGlobalWindow(),this.setupEventListeners()}return t(s,[{key:"initializeGlobalWindow",value:function(){var t=this;"undefined"!=typeof window&&(window.__AUTH_MFE__={getAuthData:function(){return t.authData},setAuthData:function(e){return t.updateAuthData(e)},subscribe:function(e,n){return t.subscribe(e,n)},unsubscribe:function(e,n){return t.unsubscribe(e,n)},version:"1.0.0"},this.isInitialized=!0)}},{key:"setupEventListeners",value:function(){"undefined"!=typeof window&&(window.addEventListener("auth:request",this.handleAuthRequest.bind(this)),window.addEventListener("auth:login",this.handleLoginRequest.bind(this)),window.addEventListener("auth:logout",this.handleLogoutRequest.bind(this)))}},{key:"handleAuthRequest",value:function(t){var n=(t.detail||{}).microFrontendId;n&&window.dispatchEvent(new CustomEvent("auth:response",{detail:e(e({},this.authData),{},{microFrontendId:n,timestamp:Date.now()})}))}},{key:"handleLoginRequest",value:function(t){var e=(t.detail||{}).microFrontendId;window.dispatchEvent(new CustomEvent("auth:hostLogin",{detail:{microFrontendId:e,timestamp:Date.now()}}))}},{key:"handleLogoutRequest",value:function(t){var e=(t.detail||{}).microFrontendId;window.dispatchEvent(new CustomEvent("auth:hostLogout",{detail:{microFrontendId:e,timestamp:Date.now()}}))}},{key:"updateAuthData",value:function(t){var n=this;this.authData=e(e(e({},this.authData),t),{},{timestamp:Date.now()}),this.listeners.forEach((function(t,i){t.forEach((function(t){try{t(e(e({},n.authData),{},{microFrontendId:i}))}catch(t){console.error("Auth MFE: Error notifying ".concat(i,":"),t)}}))})),window.dispatchEvent(new CustomEvent("auth:stateChanged",{detail:this.authData}))}},{key:"subscribe",value:function(t,n){this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(n),n(e(e({},this.authData),{},{microFrontendId:t}))}},{key:"unsubscribe",value:function(t,e){var n=this.listeners.get(t);if(n){var i=n.indexOf(e);i>-1&&n.splice(i,1),0===n.length&&this.listeners.delete(t)}}},{key:"getAuthData",value:function(){return e({},this.authData)}},{key:"isReady",value:function(){return this.isInitialized&&"undefined"!=typeof window&&!!window.__AUTH_MFE__}},{key:"getDebugInfo",value:function(){return{isInitialized:this.isInitialized,authData:this.authData,subscriberCount:Array.from(this.listeners.values()).reduce((function(t,e){return t+e.length}),0),subscribers:Array.from(this.listeners.keys()),windowAvailable:"undefined"!=typeof window,globalObjectAvailable:"undefined"!=typeof window&&!!window.__AUTH_MFE__}}}],[{key:"getInstance",value:function(){return s.instance||(s.instance=new s),s.instance}}])}();export{s as default};
2
- //# sourceMappingURL=auth-mfe-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-mfe-manager.js","sources":["../../src/mfe-auth/auth-mfe-manager.ts"],"sourcesContent":["import { AuthEventData, AuthEventListener, defaultAuthData } from './auth-types'\r\n\r\n/**\r\n * Global Authentication Manager for Module Federation\r\n * Manages authentication state across host and micro frontend applications\r\n */\r\nclass AuthMFEManager {\r\n private static instance: AuthMFEManager\r\n private authData: AuthEventData = defaultAuthData\r\n private listeners: Map<string, AuthEventListener[]> = new Map()\r\n private isInitialized = false\r\n\r\n private constructor() {\r\n this.initializeGlobalWindow()\r\n this.setupEventListeners()\r\n }\r\n\r\n /**\r\n * Get singleton instance\r\n */\r\n static getInstance(): AuthMFEManager {\r\n if (!AuthMFEManager.instance) {\r\n AuthMFEManager.instance = new AuthMFEManager()\r\n }\r\n return AuthMFEManager.instance\r\n }\r\n\r\n /**\r\n * Initialize global window object for cross-component communication\r\n */\r\n private initializeGlobalWindow(): void {\r\n if (typeof window !== 'undefined') {\r\n ;(window as any).__AUTH_MFE__ = {\r\n getAuthData: () => this.authData,\r\n setAuthData: (data: AuthEventData) => this.updateAuthData(data),\r\n subscribe: (microFrontendId: string, callback: AuthEventListener) => this.subscribe(microFrontendId, callback),\r\n unsubscribe: (microFrontendId: string, callback: AuthEventListener) => this.unsubscribe(microFrontendId, callback),\r\n version: '1.0.0'\r\n }\r\n this.isInitialized = true\r\n }\r\n }\r\n\r\n /**\r\n * Setup event listeners for authentication events\r\n */\r\n private setupEventListeners(): void {\r\n if (typeof window === 'undefined') return\r\n\r\n // Listen for auth requests from micro frontends\r\n window.addEventListener('auth:request', this.handleAuthRequest.bind(this) as EventListener)\r\n\r\n // Listen for login/logout requests\r\n window.addEventListener('auth:login', this.handleLoginRequest.bind(this) as EventListener)\r\n window.addEventListener('auth:logout', this.handleLogoutRequest.bind(this) as EventListener)\r\n }\r\n\r\n /**\r\n * Handle authentication state requests\r\n */\r\n private handleAuthRequest(event: Event): void {\r\n const customEvent = event as CustomEvent\r\n const { microFrontendId } = customEvent.detail || {}\r\n\r\n if (microFrontendId) {\r\n // Send current auth state to requesting micro frontend\r\n window.dispatchEvent(\r\n new CustomEvent('auth:response', {\r\n detail: { ...this.authData, microFrontendId, timestamp: Date.now() }\r\n })\r\n )\r\n }\r\n }\r\n\r\n /**\r\n * Handle login requests from micro frontends\r\n */\r\n private handleLoginRequest(event: Event): void {\r\n const customEvent = event as CustomEvent\r\n const { microFrontendId } = customEvent.detail || {}\r\n\r\n // Dispatch to host application\r\n window.dispatchEvent(\r\n new CustomEvent('auth:hostLogin', {\r\n detail: { microFrontendId, timestamp: Date.now() }\r\n })\r\n )\r\n }\r\n\r\n /**\r\n * Handle logout requests from micro frontends\r\n */\r\n private handleLogoutRequest(event: Event): void {\r\n const customEvent = event as CustomEvent\r\n const { microFrontendId } = customEvent.detail || {}\r\n\r\n // Dispatch to host application\r\n window.dispatchEvent(\r\n new CustomEvent('auth:hostLogout', {\r\n detail: { microFrontendId, timestamp: Date.now() }\r\n })\r\n )\r\n }\r\n\r\n /**\r\n * Update authentication data and notify all subscribers\r\n */\r\n updateAuthData(newData: Partial<AuthEventData>): void {\r\n this.authData = { ...this.authData, ...newData, timestamp: Date.now() }\r\n\r\n // Notify all subscribed micro frontends\r\n this.listeners.forEach((callbacks, microFrontendId) => {\r\n callbacks.forEach((callback) => {\r\n try {\r\n callback({ ...this.authData, microFrontendId })\r\n } catch (error) {\r\n console.error(`Auth MFE: Error notifying ${microFrontendId}:`, error)\r\n }\r\n })\r\n })\r\n\r\n // Broadcast to all components via custom event\r\n window.dispatchEvent(new CustomEvent('auth:stateChanged', { detail: this.authData }))\r\n }\r\n\r\n /**\r\n * Subscribe to authentication changes\r\n */\r\n subscribe(microFrontendId: string, callback: AuthEventListener): void {\r\n if (!this.listeners.has(microFrontendId)) {\r\n this.listeners.set(microFrontendId, [])\r\n }\r\n this.listeners.get(microFrontendId)!.push(callback)\r\n\r\n // Immediately provide current auth state\r\n callback({ ...this.authData, microFrontendId })\r\n }\r\n\r\n /**\r\n * Unsubscribe from authentication changes\r\n */\r\n unsubscribe(microFrontendId: string, callback: AuthEventListener): void {\r\n const callbacks = this.listeners.get(microFrontendId)\r\n if (callbacks) {\r\n const index = callbacks.indexOf(callback)\r\n if (index > -1) {\r\n callbacks.splice(index, 1)\r\n }\r\n\r\n // Clean up empty listener arrays\r\n if (callbacks.length === 0) {\r\n this.listeners.delete(microFrontendId)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Get current authentication data\r\n */\r\n getAuthData(): AuthEventData {\r\n return { ...this.authData }\r\n }\r\n\r\n /**\r\n * Check if manager is initialized\r\n */\r\n isReady(): boolean {\r\n return this.isInitialized && typeof window !== 'undefined' && !!(window as any).__AUTH_MFE__\r\n }\r\n\r\n /**\r\n * Get debug information\r\n */\r\n getDebugInfo() {\r\n return {\r\n isInitialized: this.isInitialized,\r\n authData: this.authData,\r\n subscriberCount: Array.from(this.listeners.values()).reduce((sum, arr) => sum + arr.length, 0),\r\n subscribers: Array.from(this.listeners.keys()),\r\n windowAvailable: typeof window !== 'undefined',\r\n globalObjectAvailable: typeof window !== 'undefined' && !!(window as any).__AUTH_MFE__\r\n }\r\n }\r\n}\r\n\r\nexport default AuthMFEManager\r\n"],"names":["AuthMFEManager","_classCallCheck","_defineProperty","defaultAuthData","this","Map","initializeGlobalWindow","setupEventListeners","_createClass","key","value","_this","window","__AUTH_MFE__","getAuthData","authData","setAuthData","data","updateAuthData","subscribe","microFrontendId","callback","unsubscribe","version","isInitialized","addEventListener","handleAuthRequest","bind","handleLoginRequest","handleLogoutRequest","event","detail","dispatchEvent","CustomEvent","_objectSpread","timestamp","Date","now","newData","_this2","listeners","forEach","callbacks","error","console","concat","has","set","get","push","index","indexOf","splice","length","subscriberCount","Array","from","values","reduce","sum","arr","subscribers","keys","windowAvailable","globalObjectAvailable","instance"],"mappings":"oLAEA,IAIMA,EAAc,WAMlB,SAAAA,IAAAC,OAAAD,GAAAE,kBAJkCC,GAAeD,EACKE,KAAA,YAAA,IAAIC,KAAKH,wBACvC,GAGtBE,KAAKE,yBACLF,KAAKG,qBACP,CAEA,OAAAC,EAAAR,EAAA,CAAA,CAAAS,IAAA,yBAAAC,MAaQ,WAAsB,IAAAC,EAAAP,KACN,oBAAXQ,SACPA,OAAeC,aAAe,CAC9BC,YAAa,WAAF,OAAQH,EAAKI,QAAQ,EAChCC,YAAa,SAACC,GAAmB,OAAKN,EAAKO,eAAeD,EAAK,EAC/DE,UAAW,SAACC,EAAyBC,GAA2B,OAAKV,EAAKQ,UAAUC,EAAiBC,EAAS,EAC9GC,YAAa,SAACF,EAAyBC,GAA2B,OAAKV,EAAKW,YAAYF,EAAiBC,EAAS,EAClHE,QAAS,SAEXnB,KAAKoB,eAAgB,EAEzB,GAEA,CAAAf,IAAA,sBAAAC,MAGQ,WACgB,oBAAXE,SAGXA,OAAOa,iBAAiB,eAAgBrB,KAAKsB,kBAAkBC,KAAKvB,OAGpEQ,OAAOa,iBAAiB,aAAcrB,KAAKwB,mBAAmBD,KAAKvB,OACnEQ,OAAOa,iBAAiB,cAAerB,KAAKyB,oBAAoBF,KAAKvB,OACvE,GAEA,CAAAK,IAAA,oBAAAC,MAGQ,SAAkBoB,GACxB,IACQV,GADYU,EACoBC,QAAU,CAAE,GAA5CX,gBAEJA,GAEFR,OAAOoB,cACL,IAAIC,YAAY,gBAAiB,CAC/BF,OAAMG,EAAAA,EAAO,CAAA,EAAA9B,KAAKW,UAAQ,GAAA,CAAEK,gBAAAA,EAAiBe,UAAWC,KAAKC,U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AAKoC,UAAUQ,IAAI5B,GACrC,GAAIsB,EAAW,CACb,IAAMQ,EAAQR,EAAUS,QAAQ9B,GAC5B6B,GAAQ,GACVR,EAAUU,OAAOF,EAAO,GAID,IAArBR,EAAUW,QACZjD,KAAKoC,UAAgB,OAACpB,EAEzB,CACH,GAEA,CAAAX,IAAA,cAAAC,MAGA,WACE,OAAAwB,EAAA,CAAA,EAAY9B,KAAKW,SACnB,GAEA,CAAAN,IAAA,UAAAC,MAGA,WACE,OAAON,KAAKoB,eAAmC,oBAAXZ,UAA6BA,OAAeC,YAClF,GAEA,CAAAJ,IAAA,eAAAC,MAGA,WACE,MAAO,CACLc,cAAepB,KAAKoB,cACpBT,SAAUX,KAAKW,SACfuC,gBAAiBC,MAAMC,KAAKpD,KAAKoC,UAAUiB,UAAUC,QAAO,SAACC,EAAKC,GAAG,OAAKD,EAAMC,EAAIP,MAAM,GAAE,GAC5FQ,YAAaN,MAAMC,KAAKpD,KAAKoC,UAAUsB,QACvCC,gBAAmC,oBAAXnD,OACxBoD,sBAAyC,oBAAXpD,UAA6BA,OAAeC,aAE9E,IAAC,CAAA,CAAAJ,IAAA,cAAAC,MAlKD,WAIE,OAHKV,EAAeiE,WAClBjE,EAAeiE,SAAW,IAAIjE,GAEzBA,EAAeiE,QACxB,IAAC,CAnBiB"}
@@ -1,2 +0,0 @@
1
- import{slicedToArray as e,asyncToGenerator as t,regenerator as n,objectSpread2 as r}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a,Fragment as o,jsxs as i}from"react/jsx-runtime";import{useState as s,useCallback as u,useEffect as d}from"react";import{authService as c}from"partner-oidc-auth";import{AuthStatus as l}from"./auth-enums.js";import{defaultAuthData as v}from"./auth-types.js";import m from"./auth-mfe-manager.js";var f=function(i){var f=i.children,p=s(v),h=e(p,2);h[0];var g=h[1],w=s(!0),E=e(w,2);E[0];var U=E[1],A=m.getInstance(),b=u(t(n().m((function e(){var t,r,a,o,i;return n().w((function(e){for(;;)switch(e.n){case 0:return e.p=0,U(!0),e.n=1,c.isAuthenticated();case 1:if(!e.v){e.n=3;break}return e.n=2,c.getUser();case 2:t=e.v,r={status:l.AUTHENTICATED,email:(null==t?void 0:t.email)||"Unknown Email",displayName:(null==t?void 0:t.name)||"Unknown User",avatar:(null==t?void 0:t.picture)||"Unknown Avatar",timestamp:Date.now()},g(r),A.updateAuthData(r),e.n=4;break;case 3:a={status:l.UNAUTHENTICATED,timestamp:Date.now()},g(a),A.updateAuthData(a);case 4:e.n=6;break;case 5:e.p=5,i=e.v,console.error("Auth MFE: Failed to initialize authentication:",i),o={status:l.ERROR,error:i instanceof Error?i.message:"Authentication initialization failed",timestamp:Date.now()},g(o),A.updateAuthData(o);case 6:return e.p=6,U(!1),e.f(6);case 7:return e.a(2)}}),e,null,[[0,5,6,7]])}))),[A]),D=u(t(n().m((function e(){var t,a;return n().w((function(e){for(;;)switch(e.n){case 0:return e.p=0,g((function(e){return r(r({},e),{},{status:l.AUTHENTICATING,timestamp:Date.now()})})),e.n=1,c.signIn({returnUrl:c.getReturnUrl()});case 1:e.n=3;break;case 2:e.p=2,a=e.v,console.error("Auth MFE: Login failed:",a),t={status:l.ERROR,error:a instanceof Error?a.message:"Login failed",timestamp:Date.now()},g(t),A.updateAuthData(t);case 3:return e.a(2)}}),e,null,[[0,2]])}))),[A]),T=u(t(n().m((function e(){var t,r,a;return n().w((function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,c.signOut({returnUrl:c.getReturnUrl()});case 1:t={status:l.UNAUTHENTICATED,timestamp:Date.now()},g(t),A.updateAuthData(t),e.n=3;break;case 2:e.p=2,a=e.v,console.error("Auth MFE: Logout failed:",a),r={status:l.UNAUTHENTICATED,error:a instanceof Error?a.message:"Logout failed",timestamp:Date.now()},g(r),A.updateAuthData(r);case 3:return e.a(2)}}),e,null,[[0,2]])}))),[A]);return d((function(){b()}),[b]),d((function(){var e=function(){return D()},t=function(){return T()};return window.addEventListener("auth:hostLogin",e),window.addEventListener("auth:hostLogout",t),function(){window.removeEventListener("auth:hostLogin",e),window.removeEventListener("auth:hostLogout",t)}}),[D,T]),d((function(){var e=function(){b()};return c.userManager&&(c.userManager.events.addUserLoaded(e),c.userManager.events.addUserUnloaded(e),c.userManager.events.addUserSignedOut(e)),function(){c.userManager&&(c.userManager.events.removeUserLoaded(e),c.userManager.events.removeUserUnloaded(e),c.userManager.events.removeUserSignedOut(e))}}),[b]),a(o,{children:f})},p=function(t){var n,o,u,c=t.position,l=void 0===c?{bottom:"60px",left:"10px"}:c,v=s({}),f=e(v,2),p=f[0],h=f[1],g=m.getInstance();return d((function(){var e=function(){h(g.getDebugInfo())};e();var t=function(){return e()};window.addEventListener("auth:stateChanged",t);var n=setInterval(e,2e3);return function(){window.removeEventListener("auth:stateChanged",t),clearInterval(n)}}),[g]),"production"===process.env.NODE_ENV?null:i("div",{style:r({position:"fixed",background:"rgba(0, 0, 0, 0.9)",color:"white",padding:"10px",borderRadius:"5px",fontSize:"12px",fontFamily:"monospace",maxWidth:"300px",zIndex:9999},l),children:[a("div",{style:{fontWeight:"bold",marginBottom:"5px"},children:"🔐 Auth MFE Debug (Host)"}),i("div",{children:["Status: ",null===(n=p.authData)||void 0===n?void 0:n.status]}),i("div",{children:["User: ",(null===(o=p.authData)||void 0===o?void 0:o.displayName)||"None"]}),i("div",{children:["Subscribers: ",p.subscriberCount]}),i("div",{children:["MFEs: ",(null===(u=p.subscribers)||void 0===u?void 0:u.join(", "))||"None"]}),i("div",{children:["Global Ready: ",p.globalObjectAvailable?"✅":"❌"]}),i("div",{children:["Initialized: ",p.isInitialized?"✅":"❌"]})]})};export{p as AuthMFEProviderDebug,f as default};
2
- //# sourceMappingURL=auth-mfe-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-mfe-provider.js","sources":["../../src/mfe-auth/auth-mfe-provider.tsx"],"sourcesContent":["import React, { useEffect, useState, useCallback, CSSProperties, FC } from 'react'\r\nimport { authService } from 'partner-oidc-auth'\r\nimport { AuthStatus } from './auth-enums'\r\nimport { AuthEventData, defaultAuthData } from './auth-types'\r\nimport AuthMFEManager from './auth-mfe-manager'\r\n\r\nexport interface AuthMFEProviderProps {\r\n children: React.ReactNode\r\n}\r\n\r\n/**\r\n * Authentication MFE Provider Component\r\n * Provides authentication state management for the host application\r\n * Handles communication with micro frontends via global window object\r\n */\r\nconst AuthMFEProvider: FC<AuthMFEProviderProps> = ({ children }) => {\r\n const [authData, setAuthData] = useState<AuthEventData>(defaultAuthData)\r\n const [isLoading, setIsLoading] = useState(true)\r\n\r\n // Get the auth manager instance\r\n const authManager = AuthMFEManager.getInstance()\r\n\r\n /**\r\n * Initialize authentication state from auth service\r\n */\r\n const initializeAuth = useCallback(async () => {\r\n try {\r\n setIsLoading(true)\r\n\r\n // Check if user is already authenticated\r\n const isAuthenticated = await authService.isAuthenticated()\r\n\r\n if (isAuthenticated) {\r\n const user = await authService.getUser()\r\n const newAuthData: AuthEventData = {\r\n status: AuthStatus.AUTHENTICATED,\r\n email: user?.email || 'Unknown Email',\r\n displayName: user?.name || 'Unknown User',\r\n avatar: user?.picture || 'Unknown Avatar',\r\n timestamp: Date.now()\r\n }\r\n\r\n setAuthData(newAuthData)\r\n authManager.updateAuthData(newAuthData)\r\n } else {\r\n const unauthenticatedData: AuthEventData = {\r\n status: AuthStatus.UNAUTHENTICATED,\r\n timestamp: Date.now()\r\n }\r\n\r\n setAuthData(unauthenticatedData)\r\n authManager.updateAuthData(unauthenticatedData)\r\n }\r\n } catch (error) {\r\n console.error('Auth MFE: Failed to initialize authentication:', error)\r\n const errorData: AuthEventData = {\r\n status: AuthStatus.ERROR,\r\n error: error instanceof Error ? error.message : 'Authentication initialization failed',\r\n timestamp: Date.now()\r\n }\r\n\r\n setAuthData(errorData)\r\n authManager.updateAuthData(errorData)\r\n } finally {\r\n setIsLoading(false)\r\n }\r\n }, [authManager])\r\n\r\n /**\r\n * Handle login requests from micro frontends\r\n */\r\n const handleLoginRequest = useCallback(async () => {\r\n try {\r\n setAuthData((prev) => ({\r\n ...prev,\r\n status: AuthStatus.AUTHENTICATING,\r\n timestamp: Date.now()\r\n }))\r\n\r\n await authService.signIn({ returnUrl: authService.getReturnUrl() })\r\n // Auth state will be updated by the redirect callback\r\n } catch (error) {\r\n console.error('Auth MFE: Login failed:', error)\r\n const errorData: AuthEventData = {\r\n status: AuthStatus.ERROR,\r\n error: error instanceof Error ? error.message : 'Login failed',\r\n timestamp: Date.now()\r\n }\r\n\r\n setAuthData(errorData)\r\n authManager.updateAuthData(errorData)\r\n }\r\n }, [authManager])\r\n\r\n /**\r\n * Handle logout requests from micro frontends\r\n */\r\n const handleLogoutRequest = useCallback(async () => {\r\n try {\r\n await authService.signOut({ returnUrl: authService.getReturnUrl() })\r\n\r\n const loggedOutData: AuthEventData = {\r\n status: AuthStatus.UNAUTHENTICATED,\r\n timestamp: Date.now()\r\n }\r\n\r\n setAuthData(loggedOutData)\r\n authManager.updateAuthData(loggedOutData)\r\n } catch (error) {\r\n console.error('Auth MFE: Logout failed:', error)\r\n // Even if logout fails, treat as logged out\r\n const loggedOutData: AuthEventData = {\r\n status: AuthStatus.UNAUTHENTICATED,\r\n error: error instanceof Error ? error.message : 'Logout failed',\r\n timestamp: Date.now()\r\n }\r\n\r\n setAuthData(loggedOutData)\r\n authManager.updateAuthData(loggedOutData)\r\n }\r\n }, [authManager])\r\n\r\n // Initialize authentication on mount\r\n useEffect(() => {\r\n initializeAuth()\r\n }, [initializeAuth])\r\n\r\n // Listen for host authentication events\r\n useEffect(() => {\r\n const handleHostLogin = () => handleLoginRequest()\r\n const handleHostLogout = () => handleLogoutRequest()\r\n\r\n window.addEventListener('auth:hostLogin', handleHostLogin)\r\n window.addEventListener('auth:hostLogout', handleHostLogout)\r\n\r\n return () => {\r\n window.removeEventListener('auth:hostLogin', handleHostLogin)\r\n window.removeEventListener('auth:hostLogout', handleHostLogout)\r\n }\r\n }, [handleLoginRequest, handleLogoutRequest])\r\n\r\n // Listen for auth service changes (e.g., from redirect callbacks)\r\n useEffect(() => {\r\n const handleAuthChange = () => {\r\n // Re-initialize auth state when auth service state changes\r\n initializeAuth()\r\n }\r\n\r\n // Listen for user loaded events from oidc-client\r\n if (authService.userManager) {\r\n authService.userManager.events.addUserLoaded(handleAuthChange)\r\n authService.userManager.events.addUserUnloaded(handleAuthChange)\r\n authService.userManager.events.addUserSignedOut(handleAuthChange)\r\n }\r\n\r\n return () => {\r\n if (authService.userManager) {\r\n authService.userManager.events.removeUserLoaded(handleAuthChange)\r\n authService.userManager.events.removeUserUnloaded(handleAuthChange)\r\n authService.userManager.events.removeUserSignedOut(handleAuthChange)\r\n }\r\n }\r\n }, [initializeAuth])\r\n\r\n return <>{children}</>\r\n}\r\n\r\nexport default AuthMFEProvider\r\n\r\nexport interface IAuthMFEProviderDebugProps {\r\n position?: Pick<CSSProperties, 'top' | 'left' | 'right' | 'bottom'>\r\n}\r\n\r\n/**\r\n * Debug component to show current authentication state\r\n * Only renders in development mode\r\n */\r\nexport const AuthMFEProviderDebug: FC<IAuthMFEProviderDebugProps> = (props) => {\r\n const { position = { bottom: '60px', left: '10px' } } = props\r\n const [debugInfo, setDebugInfo] = useState<any>({})\r\n const authManager = AuthMFEManager.getInstance()\r\n\r\n useEffect(() => {\r\n const updateDebugInfo = () => {\r\n setDebugInfo(authManager.getDebugInfo())\r\n }\r\n\r\n updateDebugInfo()\r\n\r\n // Update debug info when auth state changes\r\n const handleAuthChange = () => updateDebugInfo()\r\n window.addEventListener('auth:stateChanged', handleAuthChange)\r\n\r\n const interval = setInterval(updateDebugInfo, 2000) // Update every 2 seconds\r\n\r\n return () => {\r\n window.removeEventListener('auth:stateChanged', handleAuthChange)\r\n clearInterval(interval)\r\n }\r\n }, [authManager])\r\n\r\n // Only show in development\r\n if (process.env.NODE_ENV === 'production') {\r\n return null\r\n }\r\n\r\n return (\r\n <div\r\n style={{\r\n position: 'fixed',\r\n background: 'rgba(0, 0, 0, 0.9)',\r\n color: 'white',\r\n padding: '10px',\r\n borderRadius: '5px',\r\n fontSize: '12px',\r\n fontFamily: 'monospace',\r\n maxWidth: '300px',\r\n zIndex: 9999,\r\n ...position\r\n }}\r\n >\r\n <div style={{ fontWeight: 'bold', marginBottom: '5px' }}>🔐 Auth MFE Debug (Host)</div>\r\n <div>Status: {debugInfo.authData?.status}</div>\r\n <div>User: {debugInfo.authData?.displayName || 'None'}</div>\r\n <div>Subscribers: {debugInfo.subscriberCount}</div>\r\n <div>MFEs: {debugInfo.subscribers?.join(', ') || 'None'}</div>\r\n <div>Global Ready: {debugInfo.globalObjectAvailable ? '✅' : '❌'}</div>\r\n <div>Initialized: {debugInfo.isInitialized ? '✅' : '❌'}</div>\r\n </div>\r\n )\r\n}\r\n"],"names":["AuthMFEProvider","_ref","children","_useState","useState","defaultAuthData","_useState2","_slicedToArray","setAuthData","_useState3","_useState4","setIsLoading","authManager","AuthMFEManager","getInstance","initializeAuth","useCallback","_asyncToGenerator","_regenerator","m","_callee","user","newAuthData","unauthenticatedData","errorData","_t","w","_context","n","p","authService","isAuthenticated","v","getUser","status","AuthStatus","AUTHENTICATED","email","displayName","name","avatar","picture","timestamp","Date","now","updateAuthData","UNAUTHENTICATED","console","error","ERROR","Error","message","f","a","handleLoginRequest","_callee2","_t2","_context2","prev","_objectSpread","AUTHENTICATING","signIn","returnUrl","getReturnUrl","handleLogoutRequest","_callee3","loggedOutData","_loggedOutData","_t3","_context3","signOut","useEffect","handleHostLogin","handleHostLogout","window","addEventListener","removeEventListener","handleAuthChange","userManager","events","addUserLoaded","addUserUnloaded","addUserSignedOut","removeUserLoaded","removeUserUnloaded","removeUserSignedOut","_jsx","_Fragment","AuthMFEProviderDebug","props","_debugInfo$authData","_debugInfo$authData2","_debugInfo$subscriber","_props$position","position","bottom","left","_useState5","_useState6","debugInfo","setDebugInfo","updateDebugInfo","getDebugInfo","interval","setInterval","clearInterval","process","env","NODE_ENV","_jsxs","style","background","color","padding","borderRadius","fontSize","fontFamily","maxWidth","zIndex","fontWeight","marginBottom","authData","sub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A/B,OAAA,EAArBA,EAAuBgC,KAAK,QAAS,UACjDf,EAAA,MAAA,CAAA3G,SAAA,CAAA,iBAAoBiG,EAAU0B,sBAAwB,IAAM,OAC5DhB,EAAA,MAAA,CAAA3G,SAAA,CAAA,gBAAmBiG,EAAU2B,cAAgB,IAAM,SAGzD"}
@@ -1,2 +0,0 @@
1
- import{AuthStatus as t}from"./auth-enums.js";var a={status:t.UNAUTHENTICATED,timestamp:Date.now()};export{a as defaultAuthData};
2
- //# sourceMappingURL=auth-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-types.js","sources":["../../src/mfe-auth/auth-types.ts"],"sourcesContent":["import { AuthStatus } from './auth-enums'\r\n\r\n/**\r\n * Authentication Event Data Interface\r\n * Structure for communication between host and micro frontends\r\n */\r\nexport interface AuthEventData {\r\n /** Current authentication status */\r\n status: AuthStatus\r\n \r\n /** User display name (if authenticated) */\r\n displayName?: string\r\n \r\n /** User avatar URL (if authenticated) */\r\n avatar?: string\r\n \r\n /** Unique user identifier (if authenticated) */\r\n userId?: string\r\n \r\n /** User email address (if authenticated) */\r\n email?: string\r\n \r\n /** Additional user profile data */\r\n profile?: Record<string, any>\r\n \r\n /** Error message (if status is ERROR) */\r\n error?: string\r\n \r\n /** Timestamp of the authentication event */\r\n timestamp: number\r\n \r\n /** Source micro frontend identifier */\r\n microFrontendId?: string\r\n}\r\n\r\n/**\r\n * Authentication Event Listener Type\r\n */\r\nexport type AuthEventListener = (data: AuthEventData) => void\r\n\r\n/**\r\n * Default authentication data for unauthenticated state\r\n */\r\nexport const defaultAuthData: AuthEventData = {\r\n status: AuthStatus.UNAUTHENTICATED,\r\n timestamp: Date.now()\r\n}\r\n"],"names":["defaultAuthData","status","AuthStatus","UNAUTHENTICATED","timestamp","Date","now"],"mappings":"6CA2CO,IAAMA,EAAiC,CAC5CC,OAAQC,EAAWC,gBACnBC,UAAWC,KAAKC"}
@@ -1,2 +0,0 @@
1
- export{AuthStatus,MicroFrontendType}from"./auth-enums.js";export{defaultAuthData}from"./auth-types.js";export{default as AuthMFEManager}from"./auth-mfe-manager.js";export{default as AuthMFEProvider,AuthMFEProviderDebug}from"./auth-mfe-provider.js";export{MicroFrontendAuth,MicroFrontendAuthConsumer,MicroFrontendAuthDebug,microFrontendAuthUtils,useMicroFrontendAuth,useMicroFrontendAuthActions,withMicroFrontendAuth}from"./micro-frontend-auth-hooks.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import{createClass as t,objectSpread2 as e,asyncToGenerator as n,slicedToArray as i,regenerator as r,classCallCheck as o,defineProperty as s}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a,Fragment as u,jsxs as d}from"react/jsx-runtime";import{useState as h,useEffect as c,useCallback as l}from"react";import{defaultAuthData as f}from"./auth-types.js";import{AuthStatus as m}from"./auth-enums.js";var v=function(){return t((function t(e){o(this,t),s(this,"authData",f),s(this,"listeners",[]),s(this,"retryCount",0),s(this,"isInitialized",!1),s(this,"initPromise",null),this.microFrontendId=e,this.initialize()}),[{key:"initialize",value:(a=n(r().m((function t(){return r().w((function(t){for(;;)switch(t.n){case 0:if(!this.initPromise){t.n=1;break}return t.a(2,this.initPromise);case 1:return this.initPromise=this.tryInitialize(),t.a(2,this.initPromise)}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"tryInitialize",value:(i=n(r().m((function t(){var e=this;return r().w((function(t){for(;;)if(0===t.n)return t.a(2,new Promise((function(t,n){var i=function(){"undefined"!=typeof window&&window.__AUTH_MFE__?(e.setupConnection(),e.isInitialized=!0,t()):e.retryCount<20?(e.retryCount++,setTimeout(i,500)):n(new Error("Failed to connect to global auth manager"))};i()})))}),t)}))),function(){return i.apply(this,arguments)})},{key:"setupConnection",value:function(){"undefined"!=typeof window&&window.__AUTH_MFE__&&(window.__AUTH_MFE__.subscribe(this.microFrontendId,this.handleAuthChange.bind(this)),window.addEventListener("auth:response",this.handleAuthResponse.bind(this)),window.addEventListener("auth:stateChanged",this.handleStateChanged.bind(this)),this.requestAuthState())}},{key:"handleAuthChange",value:function(t){this.authData=e(e({},t),{},{microFrontendId:this.microFrontendId}),this.notifyListeners()}},{key:"handleAuthResponse",value:function(t){var e=t.detail;e&&e.microFrontendId===this.microFrontendId&&(this.authData=e,this.notifyListeners())}},{key:"handleStateChanged",value:function(t){var n=t.detail;n&&(this.authData=e(e({},n),{},{microFrontendId:this.microFrontendId}),this.notifyListeners())}},{key:"requestAuthState",value:function(){window.dispatchEvent(new CustomEvent("auth:request",{detail:{microFrontendId:this.microFrontendId,timestamp:Date.now()}}))}},{key:"notifyListeners",value:function(){var t=this;this.listeners.forEach((function(e){try{e(t.authData)}catch(e){console.error("Auth MFE: Error in listener for ".concat(t.microFrontendId,":"),e)}}))}},{key:"subscribe",value:function(t){var e=this;return this.listeners.push(t),this.isInitialized&&t(this.authData),function(){var n=e.listeners.indexOf(t);n>-1&&e.listeners.splice(n,1)}}},{key:"getAuthData",value:function(){return e({},this.authData)}},{key:"requestLogin",value:function(){window.dispatchEvent(new CustomEvent("auth:login",{detail:{microFrontendId:this.microFrontendId,timestamp:Date.now()}}))}},{key:"requestLogout",value:function(){window.dispatchEvent(new CustomEvent("auth:logout",{detail:{microFrontendId:this.microFrontendId,timestamp:Date.now()}}))}},{key:"isConnected",value:function(){return this.isInitialized&&"undefined"!=typeof window&&!!window.__AUTH_MFE__}},{key:"getDebugInfo",value:function(){return{microFrontendId:this.microFrontendId,isInitialized:this.isInitialized,isConnected:this.isConnected(),retryCount:this.retryCount,authData:this.authData,listenerCount:this.listeners.length,globalAvailable:"undefined"!=typeof window&&!!window.__AUTH_MFE__}}},{key:"destroy",value:function(){this.listeners=[],"undefined"!=typeof window&&(window.removeEventListener("auth:response",this.handleAuthResponse.bind(this)),window.removeEventListener("auth:stateChanged",this.handleStateChanged.bind(this)))}}]);var i,a}(),p=new Map;function w(t){return p.has(t)||p.set(t,new v(t)),p.get(t)}function g(t){var e=h(f),n=i(e,2),r=n[0],o=n[1],s=h(!0),a=i(s,2),u=a[0],d=a[1],v=w(t);c((function(){var t=v.subscribe((function(t){o(t),d(!1)}));return function(){t()}}),[v]);var p=l((function(){v.requestLogin()}),[v]),g=l((function(){v.requestLogout()}),[v]);return{isAuthenticated:r.status===m.AUTHENTICATED,isLoading:u||r.status===m.LOADING,isAuthenticating:r.status===m.AUTHENTICATING,hasError:r.status===m.ERROR,displayName:r.displayName,email:r.email,userId:r.userId,avatar:r.avatar,profile:r.profile,status:r.status,error:r.error,timestamp:r.timestamp,login:p,logout:g,authData:r,isConnected:v.isConnected(),debugInfo:v.getDebugInfo()}}function y(t){var e=w(t);return{login:l((function(){e.requestLogin()}),[e]),logout:l((function(){e.requestLogout()}),[e])}}function I(t){var e=t.microFrontendId,n=t.children,i=g(e);return a(u,{children:n(i)})}function C(t,n){return function(i){var r=g(n);return a(t,e(e({},i),{},{auth:r}))}}var F={getCurrentAuth:function(t){return w(t).getAuthData()},requestLogin:function(t){w(t).requestLogin()},requestLogout:function(t){w(t).requestLogout()},createAuthInstance:function(t){return w(t)}},_=function(t){var n=t.microFrontendId,i=t.position,r=void 0===i?{bottom:"60px",left:"10px"}:i,o=g(n),s=o.debugInfo,a=o.authData,u=o.isConnected;return"production"===process.env.NODE_ENV?null:d("div",{style:e({position:"fixed",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"10px",borderRadius:"5px",fontSize:"12px",fontFamily:"monospace",maxWidth:"300px",zIndex:9998},r),children:[d("div",{style:{fontWeight:"bold",marginBottom:"5px"},children:["🔗 Auth MFE Debug (",n,")"]}),d("div",{children:["Status: ",a.status]}),d("div",{children:["User: ",a.displayName||"None"]}),d("div",{children:["Connected: ",u?"✅":"❌"]}),d("div",{children:["Initialized: ",s.isInitialized?"✅":"❌"]}),d("div",{children:["Retries: ",s.retryCount]}),d("div",{children:["Listeners: ",s.listenerCount]})]})};export{v as MicroFrontendAuth,I as MicroFrontendAuthConsumer,_ as MicroFrontendAuthDebug,F as microFrontendAuthUtils,g as useMicroFrontendAuth,y as useMicroFrontendAuthActions,C as withMicroFrontendAuth};
2
- //# sourceMappingURL=micro-frontend-auth-hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"micro-frontend-auth-hooks.js","sources":["../../src/mfe-auth/micro-frontend-auth-hooks.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback, FC, CSSProperties } from 'react'\r\nimport { AuthEventData, AuthEventListener, defaultAuthData } from './auth-types'\r\nimport { AuthStatus } from './auth-enums'\r\n\r\n// Retry configuration for micro frontend initialization\r\nconst MAX_RETRIES = 20\r\nconst RETRY_DELAY = 500 // ms\r\n\r\n/**\r\n * Authentication Manager for Micro Frontends\r\n * Manages connection to global auth state via window object\r\n */\r\nclass MicroFrontendAuth {\r\n private microFrontendId: string\r\n private authData: AuthEventData = defaultAuthData\r\n private listeners: AuthEventListener[] = []\r\n private retryCount = 0\r\n private isInitialized = false\r\n private initPromise: Promise<void> | null = null\r\n\r\n constructor(microFrontendId: string) {\r\n this.microFrontendId = microFrontendId\r\n this.initialize()\r\n }\r\n\r\n /**\r\n * Initialize connection to global auth manager\r\n */\r\n private async initialize(): Promise<void> {\r\n if (this.initPromise) {\r\n return this.initPromise\r\n }\r\n\r\n this.initPromise = this.tryInitialize()\r\n return this.initPromise\r\n }\r\n\r\n private async tryInitialize(): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n const attemptConnection = () => {\r\n if (typeof window !== 'undefined' && (window as any).__AUTH_MFE__) {\r\n this.setupConnection()\r\n this.isInitialized = true\r\n resolve()\r\n } else if (this.retryCount < MAX_RETRIES) {\r\n this.retryCount++\r\n setTimeout(attemptConnection, RETRY_DELAY)\r\n } else {\r\n reject(new Error('Failed to connect to global auth manager'))\r\n }\r\n }\r\n\r\n attemptConnection()\r\n })\r\n }\r\n\r\n /**\r\n * Setup connection to global auth manager\r\n */\r\n private setupConnection(): void {\r\n if (typeof window === 'undefined' || !(window as any).__AUTH_MFE__) {\r\n return\r\n }\r\n\r\n // Subscribe to auth changes\r\n const globalAuth = (window as any).__AUTH_MFE__\r\n globalAuth.subscribe(this.microFrontendId, this.handleAuthChange.bind(this))\r\n\r\n // Listen for auth responses\r\n window.addEventListener('auth:response', this.handleAuthResponse.bind(this))\r\n window.addEventListener('auth:stateChanged', this.handleStateChanged.bind(this))\r\n\r\n // Request current auth state\r\n this.requestAuthState()\r\n }\r\n\r\n /**\r\n * Handle authentication state changes from global manager\r\n */\r\n private handleAuthChange(data: AuthEventData): void {\r\n this.authData = { ...data, microFrontendId: this.microFrontendId }\r\n this.notifyListeners()\r\n }\r\n\r\n /**\r\n * Handle auth response events\r\n */\r\n private handleAuthResponse(event: Event): void {\r\n const customEvent = event as CustomEvent\r\n const data = customEvent.detail\r\n\r\n if (data && data.microFrontendId === this.microFrontendId) {\r\n this.authData = data\r\n this.notifyListeners()\r\n }\r\n }\r\n\r\n /**\r\n * Handle global auth state changes\r\n */\r\n private handleStateChanged(event: Event): void {\r\n const customEvent = event as CustomEvent\r\n const data = customEvent.detail\r\n\r\n if (data) {\r\n this.authData = { ...data, microFrontendId: this.microFrontendId }\r\n this.notifyListeners()\r\n }\r\n }\r\n\r\n /**\r\n * Request current authentication state\r\n */\r\n private requestAuthState(): void {\r\n window.dispatchEvent(\r\n new CustomEvent('auth:request', {\r\n detail: { microFrontendId: this.microFrontendId, timestamp: Date.now() }\r\n })\r\n )\r\n }\r\n\r\n /**\r\n * Notify all listeners of auth changes\r\n */\r\n private notifyListeners(): void {\r\n this.listeners.forEach((listener) => {\r\n try {\r\n listener(this.authData)\r\n } catch (error) {\r\n console.error(`Auth MFE: Error in listener for ${this.microFrontendId}:`, error)\r\n }\r\n })\r\n }\r\n\r\n /**\r\n * Subscribe to authentication changes\r\n */\r\n subscribe(listener: AuthEventListener): () => void {\r\n this.listeners.push(listener)\r\n\r\n // Immediately provide current auth state if available\r\n if (this.isInitialized) {\r\n listener(this.authData)\r\n }\r\n\r\n // Return unsubscribe function\r\n return () => {\r\n const index = this.listeners.indexOf(listener)\r\n if (index > -1) {\r\n this.listeners.splice(index, 1)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Get current authentication data\r\n */\r\n getAuthData(): AuthEventData {\r\n return { ...this.authData }\r\n }\r\n\r\n /**\r\n * Request login from host application\r\n */\r\n requestLogin(): void {\r\n window.dispatchEvent(\r\n new CustomEvent('auth:login', {\r\n detail: { microFrontendId: this.microFrontendId, timestamp: Date.now() }\r\n })\r\n )\r\n }\r\n\r\n /**\r\n * Request logout from host application\r\n */\r\n requestLogout(): void {\r\n window.dispatchEvent(\r\n new CustomEvent('auth:logout', {\r\n detail: { microFrontendId: this.microFrontendId, timestamp: Date.now() }\r\n })\r\n )\r\n }\r\n\r\n /**\r\n * Check if connected to global auth manager\r\n */\r\n isConnected(): boolean {\r\n return this.isInitialized && typeof window !== 'undefined' && !!(window as any).__AUTH_MFE__\r\n }\r\n\r\n /**\r\n * Get debug information\r\n */\r\n getDebugInfo() {\r\n return {\r\n microFrontendId: this.microFrontendId,\r\n isInitialized: this.isInitialized,\r\n isConnected: this.isConnected(),\r\n retryCount: this.retryCount,\r\n authData: this.authData,\r\n listenerCount: this.listeners.length,\r\n globalAvailable: typeof window !== 'undefined' && !!(window as any).__AUTH_MFE__\r\n }\r\n }\r\n\r\n /**\r\n * Cleanup when component unmounts\r\n */\r\n destroy(): void {\r\n this.listeners = []\r\n if (typeof window !== 'undefined') {\r\n window.removeEventListener('auth:response', this.handleAuthResponse.bind(this))\r\n window.removeEventListener('auth:stateChanged', this.handleStateChanged.bind(this))\r\n }\r\n }\r\n}\r\n\r\n// Cache for auth instances to prevent multiple instances for same ID\r\nconst authInstances = new Map<string, MicroFrontendAuth>()\r\n\r\n/**\r\n * Get or create auth instance for micro frontend\r\n */\r\nfunction getAuthInstance(microFrontendId: string): MicroFrontendAuth {\r\n if (!authInstances.has(microFrontendId)) {\r\n authInstances.set(microFrontendId, new MicroFrontendAuth(microFrontendId))\r\n }\r\n return authInstances.get(microFrontendId)!\r\n}\r\n\r\n/**\r\n * React Hook for Micro Frontend Authentication\r\n * Primary hook for function components\r\n */\r\nexport function useMicroFrontendAuth(microFrontendId: string) {\r\n const [authData, setAuthData] = useState<AuthEventData>(defaultAuthData)\r\n const [isLoading, setIsLoading] = useState(true)\r\n\r\n const authInstance = getAuthInstance(microFrontendId)\r\n\r\n useEffect(() => {\r\n const unsubscribe = authInstance.subscribe((data) => {\r\n setAuthData(data)\r\n setIsLoading(false)\r\n })\r\n\r\n return () => {\r\n unsubscribe()\r\n }\r\n }, [authInstance])\r\n\r\n const login = useCallback(() => {\r\n authInstance.requestLogin()\r\n }, [authInstance])\r\n\r\n const logout = useCallback(() => {\r\n authInstance.requestLogout()\r\n }, [authInstance])\r\n\r\n return {\r\n // Auth status\r\n isAuthenticated: authData.status === AuthStatus.AUTHENTICATED,\r\n isLoading: isLoading || authData.status === AuthStatus.LOADING,\r\n isAuthenticating: authData.status === AuthStatus.AUTHENTICATING,\r\n hasError: authData.status === AuthStatus.ERROR,\r\n\r\n // User data\r\n displayName: authData.displayName,\r\n email: authData.email,\r\n userId: authData.userId,\r\n avatar: authData.avatar,\r\n profile: authData.profile,\r\n\r\n // Status and error\r\n status: authData.status,\r\n error: authData.error,\r\n timestamp: authData.timestamp,\r\n\r\n // Actions\r\n login,\r\n logout,\r\n\r\n // Raw data and debug\r\n authData,\r\n isConnected: authInstance.isConnected(),\r\n debugInfo: authInstance.getDebugInfo()\r\n }\r\n}\r\n\r\n/**\r\n * React Hook for Authentication Actions Only\r\n * Lightweight hook for components that only need actions\r\n */\r\nexport function useMicroFrontendAuthActions(microFrontendId: string) {\r\n const authInstance = getAuthInstance(microFrontendId)\r\n\r\n const login = useCallback(() => {\r\n authInstance.requestLogin()\r\n }, [authInstance])\r\n\r\n const logout = useCallback(() => {\r\n authInstance.requestLogout()\r\n }, [authInstance])\r\n\r\n return { login, logout }\r\n}\r\n\r\n/**\r\n * Consumer Component for Class Components or Render Props Pattern\r\n */\r\ninterface MicroFrontendAuthConsumerProps {\r\n microFrontendId: string\r\n children: (authData: ReturnType<typeof useMicroFrontendAuth>) => React.ReactNode\r\n}\r\n\r\nexport function MicroFrontendAuthConsumer({ microFrontendId, children }: MicroFrontendAuthConsumerProps) {\r\n const authData = useMicroFrontendAuth(microFrontendId)\r\n return <>{children(authData)}</>\r\n}\r\n\r\n/**\r\n * Higher-Order Component for Class Components\r\n */\r\nexport function withMicroFrontendAuth<P extends object>(\r\n Component: React.ComponentType<P & { auth: ReturnType<typeof useMicroFrontendAuth> }>,\r\n microFrontendId: string\r\n) {\r\n return function WrappedComponent(props: P) {\r\n const auth = useMicroFrontendAuth(microFrontendId)\r\n return <Component {...props} auth={auth} />\r\n }\r\n}\r\n\r\n/**\r\n * Utility functions for non-React contexts\r\n */\r\nexport const microFrontendAuthUtils = {\r\n /**\r\n * Get current auth state synchronously\r\n */\r\n getCurrentAuth: (microFrontendId: string): AuthEventData => {\r\n const authInstance = getAuthInstance(microFrontendId)\r\n return authInstance.getAuthData()\r\n },\r\n\r\n /**\r\n * Request login from any context\r\n */\r\n requestLogin: (microFrontendId: string): void => {\r\n const authInstance = getAuthInstance(microFrontendId)\r\n authInstance.requestLogin()\r\n },\r\n\r\n /**\r\n * Request logout from any context\r\n */\r\n requestLogout: (microFrontendId: string): void => {\r\n const authInstance = getAuthInstance(microFrontendId)\r\n authInstance.requestLogout()\r\n },\r\n\r\n /**\r\n * Create or get auth instance\r\n */\r\n createAuthInstance: (microFrontendId: string): MicroFrontendAuth => {\r\n return getAuthInstance(microFrontendId)\r\n }\r\n}\r\n\r\n/**\r\n * Debug component for micro frontends\r\n */\r\ninterface MicroFrontendAuthDebugProps {\r\n microFrontendId: string\r\n position?: Pick<CSSProperties, 'top' | 'left' | 'right' | 'bottom'>\r\n}\r\n\r\nexport const MicroFrontendAuthDebug: FC<MicroFrontendAuthDebugProps> = ({ microFrontendId, position = { bottom: '60px', left: '10px' } }) => {\r\n const { debugInfo, authData, isConnected } = useMicroFrontendAuth(microFrontendId)\r\n\r\n // Only show in development\r\n if (process.env.NODE_ENV === 'production') {\r\n return null\r\n }\r\n\r\n return (\r\n <div\r\n style={{\r\n position: 'fixed',\r\n background: 'rgba(0, 0, 0, 0.8)',\r\n color: 'white',\r\n padding: '10px',\r\n borderRadius: '5px',\r\n fontSize: '12px',\r\n fontFamily: 'monospace',\r\n maxWidth: '300px',\r\n zIndex: 9998,\r\n ...position\r\n }}\r\n >\r\n <div style={{ fontWeight: 'bold', marginBottom: '5px' }}>🔗 Auth MFE Debug ({microFrontendId})</div>\r\n <div>Status: {authData.status}</div>\r\n <div>User: {authData.displayName || 'None'}</div>\r\n <div>Connected: {isConnected ? '✅' : '❌'}</div>\r\n <div>Initialized: {debugInfo.isInitialized ? '✅' : '❌'}</div>\r\n <div>Retries: {debugInfo.retryCount}</div>\r\n <div>Listeners: {debugInfo.listenerCount}</div>\r\n </div>\r\n )\r\n}\r\n\r\nexport { MicroFrontendAuth }\r\n"],"names":["MicroFrontendAuth","_createClass","microFrontendId","_classCallCheck","_defineProperty","defaultAuthData","this","initialize","key","value","_initialize","_asyncToGenerator","_regenerator","m","_callee","w","_context","n","initPromise","a","tryInitialize","apply","arguments","_tryInitialize","_callee2","_this","_context2","Promise","resolve","reject","attemptConnection","window","__AUTH_MFE__","setupConnection","isInitialized","retryCount","setTimeout","Error","subscribe","handleAuthChange","bind","addEventListener","handleAuthResponse","handleStateChanged","requestAuthState","data","authData","_objectSpread","notifyListeners","event","detail","dispatchEvent","CustomEvent","timestamp","Date","now","_this2","listeners","forEach","listener","error","console","concat","_this3","push","index","indexOf","splice","isConnected","listenerCount","length","globalAvailable","removeEventListener","authInstances","Map","getAuthInstance","has","set","get","useMicroFrontendAuth","_useState","useState","_useState2","_slicedToArray","setAuthData","_useState3","_useState4","isLoading","setIsLoading","authInstance","useEffect","unsubscribe","login","useCallback","requestLogin","logout","requestLogout","isAuthenticated","status","AuthStatus","AUTHENTICATED","LOADING","isAuthenticating","AUTHENTICATING","hasError","ERROR","displayName","email","userId","avatar","profile","debugInfo","getDebugInfo","useMicroFrontendAuthActions","MicroFrontendAuthConsumer","_ref","children","_jsx","withMicroFrontendAuth","Component","props","auth","microFrontendAuthUtils","getCurrentAuth","getAuthData","createAuthInstance","MicroFrontendAuthDebug","_ref2","_ref2$position","position","bottom","left","_useMicroFrontendAuth","process","env","NODE_ENV","_jsxs","style","background","color","padding","borderRadius","fontSize","fontFamily","maxWidth","zIndex","fontWeight","marginBottom"],"mappings":"4ZAKA,IAOMA,EAAiB,WAarB,OAAAC,GALA,SAAAD,EAAYE,GAAuBC,OAAAH,GAAAI,kBANDC,GAAeD,mBACR,IAAEA,oBACtB,GAACA,wBACE,GAAKA,qBACe,MAG1CE,KAAKJ,gBAAkBA,EACvBI,KAAKC,YACP,GAEA,CAAA,CAAAC,IAAA,aAAAC,OAAAC,EAAAC,EAAAC,IAAAC,GAGQ,SAAAC,IAAA,OAAAF,IAAAG,GAAA,SAAAC,GAAA,cAAAA,EAAAC,GAAA,KAAA,EAAA,IACFX,KAAKY,YAAW,CAAAF,EAAAC,EAAA,EAAA,KAAA,CAAA,OAAAD,EAAAG,EACX,EAAAb,KAAKY,aAAW,KAAA,EAGc,OAAvCZ,KAAKY,YAAcZ,KAAKc,gBAAeJ,EAAAG,EAChC,EAAAb,KAAKY,aAAW,GAAAJ,EAAAR,UACxB,WAPuB,OAAAI,EAAAW,MAAAf,KAAAgB,UAAA,IAAA,CAAAd,IAAA,gBAAAC,OAAAc,EAAAZ,EAAAC,IAAAC,GAShB,SAAAW,IAAA,IAAAC,EAAAnB,KAAA,OAAAM,IAAAG,GAAA,SAAAW,GAAA,UAAA,IAAAA,EAAAT,EAAA,OAAAS,EAAAP,EACC,EAAA,IAAIQ,SAAQ,SAACC,EAASC,GAC3B,IAAMC,EAAoB,WACF,oBAAXC,QAA2BA,OAAeC,cACnDP,EAAKQ,kBACLR,EAAKS,eAA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CAAApB,SAAA,CAAA,WAAAtE,EAASoD,UACvBsC,4BAAY1F,EAAS4D,aAAe,UACpC8B,EAAA,MAAA,CAAApB,SAAA,CAAA,cAAiBhD,EAAc,IAAM,OACrCoE,EAAA,MAAA,CAAApB,SAAA,CAAA,gBAAmBL,EAAU7E,cAAgB,IAAM,OACnDsG,EAAe,MAAA,CAAApB,SAAA,CAAA,YAAAL,EAAU5E,cACzBqG,EAAA,MAAA,CAAApB,SAAA,CAAA,cAAiBL,EAAU1C,mBAGjC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * Authentication Status Enumeration
3
- * Defines possible states of user authentication
4
- */
5
- export declare enum AuthStatus {
6
- /** User is not authenticated */
7
- UNAUTHENTICATED = "UNAUTHENTICATED",
8
- /** User is successfully authenticated */
9
- AUTHENTICATED = "AUTHENTICATED",
10
- /** Authentication process is in progress */
11
- AUTHENTICATING = "AUTHENTICATING",
12
- /** Loading authentication state or user data */
13
- LOADING = "LOADING",
14
- /** Authentication error occurred */
15
- ERROR = "ERROR"
16
- }
17
- /**
18
- * Micro Frontend Type Enumeration
19
- * Identifies different types of micro frontend components
20
- */
21
- export declare enum MicroFrontendType {
22
- /** Main dashboard component */
23
- DASHBOARD = "DASHBOARD",
24
- /** User profile component */
25
- PROFILE = "PROFILE",
26
- /** Settings and configuration component */
27
- SETTINGS = "SETTINGS",
28
- /** Media store and gallery component */
29
- MEDIA_STORE = "MEDIA_STORE",
30
- /** Application header component */
31
- APP_HEADER = "APP_HEADER",
32
- /** Application footer component */
33
- APP_FOOTER = "APP_FOOTER",
34
- /** Video player and gallery component */
35
- VIDEO_GROUP = "VIDEO_GROUP",
36
- /** Audio track and playlist component */
37
- TRACK_GROUP = "TRACK_GROUP",
38
- /** Generic or custom micro frontend component */
39
- GENERIC = "GENERIC"
40
- }
@@ -1,68 +0,0 @@
1
- import { AuthEventData, AuthEventListener } from './auth-types';
2
- /**
3
- * Global Authentication Manager for Module Federation
4
- * Manages authentication state across host and micro frontend applications
5
- */
6
- declare class AuthMFEManager {
7
- private static instance;
8
- private authData;
9
- private listeners;
10
- private isInitialized;
11
- private constructor();
12
- /**
13
- * Get singleton instance
14
- */
15
- static getInstance(): AuthMFEManager;
16
- /**
17
- * Initialize global window object for cross-component communication
18
- */
19
- private initializeGlobalWindow;
20
- /**
21
- * Setup event listeners for authentication events
22
- */
23
- private setupEventListeners;
24
- /**
25
- * Handle authentication state requests
26
- */
27
- private handleAuthRequest;
28
- /**
29
- * Handle login requests from micro frontends
30
- */
31
- private handleLoginRequest;
32
- /**
33
- * Handle logout requests from micro frontends
34
- */
35
- private handleLogoutRequest;
36
- /**
37
- * Update authentication data and notify all subscribers
38
- */
39
- updateAuthData(newData: Partial<AuthEventData>): void;
40
- /**
41
- * Subscribe to authentication changes
42
- */
43
- subscribe(microFrontendId: string, callback: AuthEventListener): void;
44
- /**
45
- * Unsubscribe from authentication changes
46
- */
47
- unsubscribe(microFrontendId: string, callback: AuthEventListener): void;
48
- /**
49
- * Get current authentication data
50
- */
51
- getAuthData(): AuthEventData;
52
- /**
53
- * Check if manager is initialized
54
- */
55
- isReady(): boolean;
56
- /**
57
- * Get debug information
58
- */
59
- getDebugInfo(): {
60
- isInitialized: boolean;
61
- authData: AuthEventData;
62
- subscriberCount: number;
63
- subscribers: string[];
64
- windowAvailable: boolean;
65
- globalObjectAvailable: boolean;
66
- };
67
- }
68
- export default AuthMFEManager;
@@ -1,19 +0,0 @@
1
- import React, { CSSProperties, FC } from 'react';
2
- export interface AuthMFEProviderProps {
3
- children: React.ReactNode;
4
- }
5
- /**
6
- * Authentication MFE Provider Component
7
- * Provides authentication state management for the host application
8
- * Handles communication with micro frontends via global window object
9
- */
10
- declare const AuthMFEProvider: FC<AuthMFEProviderProps>;
11
- export default AuthMFEProvider;
12
- export interface IAuthMFEProviderDebugProps {
13
- position?: Pick<CSSProperties, 'top' | 'left' | 'right' | 'bottom'>;
14
- }
15
- /**
16
- * Debug component to show current authentication state
17
- * Only renders in development mode
18
- */
19
- export declare const AuthMFEProviderDebug: FC<IAuthMFEProviderDebugProps>;
@@ -1,33 +0,0 @@
1
- import { AuthStatus } from './auth-enums';
2
- /**
3
- * Authentication Event Data Interface
4
- * Structure for communication between host and micro frontends
5
- */
6
- export interface AuthEventData {
7
- /** Current authentication status */
8
- status: AuthStatus;
9
- /** User display name (if authenticated) */
10
- displayName?: string;
11
- /** User avatar URL (if authenticated) */
12
- avatar?: string;
13
- /** Unique user identifier (if authenticated) */
14
- userId?: string;
15
- /** User email address (if authenticated) */
16
- email?: string;
17
- /** Additional user profile data */
18
- profile?: Record<string, any>;
19
- /** Error message (if status is ERROR) */
20
- error?: string;
21
- /** Timestamp of the authentication event */
22
- timestamp: number;
23
- /** Source micro frontend identifier */
24
- microFrontendId?: string;
25
- }
26
- /**
27
- * Authentication Event Listener Type
28
- */
29
- export type AuthEventListener = (data: AuthEventData) => void;
30
- /**
31
- * Default authentication data for unauthenticated state
32
- */
33
- export declare const defaultAuthData: AuthEventData;
@@ -1,6 +0,0 @@
1
- export * from './auth-enums';
2
- export * from './auth-types';
3
- export { default as AuthMFEManager } from './auth-mfe-manager';
4
- export { default as AuthMFEProvider, AuthMFEProviderDebug } from './auth-mfe-provider';
5
- export { MicroFrontendAuth, MicroFrontendAuthConsumer, MicroFrontendAuthDebug } from './micro-frontend-auth-hooks';
6
- export { useMicroFrontendAuth, useMicroFrontendAuthActions, withMicroFrontendAuth, microFrontendAuthUtils } from './micro-frontend-auth-hooks';