@ibdop/platform-kit 1.0.12 → 1.0.14
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 +0 -0
- package/dist/components/ErrorBoundary.d.ts +0 -0
- package/dist/components/ErrorBoundary.d.ts.map +0 -0
- package/dist/components/Notification.d.ts +0 -0
- package/dist/components/Notification.d.ts.map +0 -0
- package/dist/components/VersionInfo.d.ts +0 -0
- package/dist/components/VersionInfo.d.ts.map +0 -0
- package/dist/components/index.d.ts +0 -0
- package/dist/components/index.d.ts.map +0 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useApi.d.ts +13 -2
- package/dist/hooks/useApi.d.ts.map +1 -1
- package/dist/hooks/useFeatures.d.ts +0 -0
- package/dist/hooks/useFeatures.d.ts.map +0 -0
- package/dist/hooks/useInfoData.d.ts +0 -0
- package/dist/hooks/useInfoData.d.ts.map +0 -0
- package/dist/hooks/usePermissions.d.ts +0 -0
- package/dist/hooks/usePermissions.d.ts.map +0 -0
- package/dist/hooks/useShellAuth.d.ts +0 -0
- package/dist/hooks/useShellAuth.d.ts.map +0 -0
- package/dist/hooks/useV1Config.d.ts +0 -0
- package/dist/hooks/useV1Config.d.ts.map +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.d.ts.map +0 -0
- package/dist/index.js +10 -10
- package/dist/index.mjs +854 -809
- package/dist/index.umd.js +9 -9
- package/dist/services/api.d.ts +0 -0
- package/dist/services/api.d.ts.map +1 -1
- package/dist/services/index.d.ts +0 -0
- package/dist/services/index.d.ts.map +0 -0
- package/dist/services/logger.d.ts +0 -0
- package/dist/services/logger.d.ts.map +0 -0
- package/dist/types/index.d.ts +0 -23
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/index.d.ts.map +0 -0
- package/dist/utils/mfeName.d.ts +0 -0
- package/dist/utils/mfeName.d.ts.map +0 -0
- package/dist/utils/shellAuth.d.ts +1 -0
- package/dist/utils/shellAuth.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/ErrorBoundary.tsx +0 -0
- package/src/components/Notification.tsx +0 -0
- package/src/components/VersionInfo.tsx +0 -0
- package/src/components/index.ts +0 -0
- package/src/global.d.ts +0 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useApi.ts +48 -40
- package/src/hooks/useFeatures.ts +0 -0
- package/src/hooks/useInfoData.ts +0 -0
- package/src/hooks/usePermissions.ts +0 -0
- package/src/hooks/useShellAuth.ts +0 -0
- package/src/hooks/useV1Config.ts +0 -0
- package/src/index.ts +0 -0
- package/src/services/api.ts +12 -1
- package/src/services/index.ts +0 -0
- package/src/services/logger.ts +0 -0
- package/src/types/index.ts +1 -24
- package/src/utils/index.ts +0 -0
- package/src/utils/mfeName.ts +0 -0
- package/src/utils/shellAuth.ts +31 -1
package/src/utils/shellAuth.ts
CHANGED
|
@@ -41,6 +41,7 @@ export function getShellAuth(): ShellAuth | null {
|
|
|
41
41
|
export function getAuthState(): {
|
|
42
42
|
isAuthenticated: boolean
|
|
43
43
|
user?: {
|
|
44
|
+
access_token?: string
|
|
44
45
|
profile?: {
|
|
45
46
|
access_token?: string
|
|
46
47
|
}
|
|
@@ -52,9 +53,38 @@ export function getAuthState(): {
|
|
|
52
53
|
return { isAuthenticated: false }
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
// Try to get token from auth.user or auth.user.profile
|
|
57
|
+
// Also try getAccessToken() method if available
|
|
58
|
+
let accessToken: string | undefined
|
|
59
|
+
|
|
60
|
+
// Use type assertion for auth object that may have getAccessToken method
|
|
61
|
+
const authWithToken = auth as unknown as {
|
|
62
|
+
getAccessToken?: () => Promise<string> | string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (auth.user?.access_token) {
|
|
66
|
+
accessToken = auth.user.access_token
|
|
67
|
+
} else if (auth.user?.profile?.access_token) {
|
|
68
|
+
accessToken = auth.user.profile.access_token
|
|
69
|
+
} else if (typeof authWithToken.getAccessToken === 'function') {
|
|
70
|
+
// Try to get token via getAccessToken method (react-oidc-context)
|
|
71
|
+
try {
|
|
72
|
+
const token = authWithToken.getAccessToken()
|
|
73
|
+
// getAccessToken can return Promise or string
|
|
74
|
+
if (token instanceof Promise) {
|
|
75
|
+
// Handle async token - this shouldn't happen in sync context but just in case
|
|
76
|
+
console.warn('[shellAuth] getAccessToken returned Promise - token may not be available synchronously')
|
|
77
|
+
} else if (typeof token === 'string') {
|
|
78
|
+
accessToken = token
|
|
79
|
+
}
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.warn('[shellAuth] Failed to get access token via getAccessToken:', e)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
55
85
|
return {
|
|
56
86
|
isAuthenticated: auth.isAuthenticated,
|
|
57
|
-
user: auth.user
|
|
87
|
+
user: auth.user ? { ...auth.user, access_token: accessToken } : undefined,
|
|
58
88
|
}
|
|
59
89
|
}
|
|
60
90
|
|