@sso-id/cli 0.2.4 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sso-id/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "description": "Official SSO.ID Developer CLI (init, decode-token, test-discovery)",
6
6
  "bin": {
@@ -8,11 +8,13 @@ export const metadata: Metadata = {
8
8
 
9
9
  export default function RootLayout({ children }: { children: React.ReactNode }) {
10
10
  return (
11
- <html lang="en">
12
- <body style={{ margin: 0, fontFamily: 'system-ui, -apple-system, sans-serif', background: '#f8fafc', color: '#0f172a' }}>
11
+ <html lang="en" suppressHydrationWarning>
12
+ <body
13
+ suppressHydrationWarning
14
+ style={{ margin: 0, fontFamily: 'system-ui, -apple-system, sans-serif', background: '#f8fafc', color: '#0f172a' }}
15
+ >
13
16
  <Providers>{children}</Providers>
14
17
  </body>
15
18
  </html>
16
19
  );
17
20
  }
18
-
@@ -7,10 +7,16 @@ import { SignInButton, UserMenu } from '@sso-id/ui';
7
7
  type Tab = 'organizations' | 'organization-units' | 'users' | 'groups' | 'scim';
8
8
 
9
9
  export default function HomePage() {
10
- const { isAuthenticated, user, isLoading } = useSsoId();
10
+ const { isAuthenticated: spaAuthed, user: spaUser, isLoading: spaLoading } = useSsoId();
11
+ const [serverUser, setServerUser] = useState<Record<string, unknown> | null>(null);
12
+ const [serverChecked, setServerChecked] = useState(false);
11
13
  const [tab, setTab] = useState<Tab>('organizations');
12
14
  const [data, setData] = useState<unknown>(null);
13
- const [scimState, setScimState] = useState<{ users: unknown[]; groups: unknown[]; events: Array<{ id: string; timestamp: string; direction: string; resourceType: string; operation: string; summary: string }> }>({
15
+ const [scimState, setScimState] = useState<{
16
+ users: unknown[];
17
+ groups: unknown[];
18
+ events: Array<{ id: string; timestamp: string; direction: string; resourceType: string; operation: string; summary: string }>;
19
+ }>({
14
20
  users: [],
15
21
  groups: [],
16
22
  events: [],
@@ -20,6 +26,22 @@ export default function HomePage() {
20
26
  const [orgId, setOrgId] = useState('');
21
27
  const [status, setStatus] = useState('');
22
28
 
29
+ const isAuthenticated = spaAuthed || Boolean(serverUser);
30
+ const activeUser = (spaUser as Record<string, unknown> | null) || serverUser;
31
+ const isLoading = spaLoading && !serverChecked;
32
+
33
+ useEffect(() => {
34
+ fetch('/api/auth/me')
35
+ .then((r) => r.json())
36
+ .then((res: { authenticated?: boolean; user?: Record<string, unknown> | null }) => {
37
+ if (res?.authenticated && res.user) {
38
+ setServerUser(res.user);
39
+ }
40
+ })
41
+ .catch(() => {})
42
+ .finally(() => setServerChecked(true));
43
+ }, []);
44
+
23
45
  async function loadTab(current: Tab) {
24
46
  setStatus('');
25
47
  if (current === 'scim') {
@@ -62,6 +84,16 @@ export default function HomePage() {
62
84
  await loadTab(tab);
63
85
  }
64
86
 
87
+ const displayIdentity = String(
88
+ activeUser?.email ||
89
+ activeUser?.['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] ||
90
+ activeUser?.name ||
91
+ activeUser?.['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'] ||
92
+ activeUser?.sub ||
93
+ activeUser?.user_id ||
94
+ '',
95
+ );
96
+
65
97
  return (
66
98
  <main style={{ maxWidth: 1080, margin: '0 auto', padding: '32px 20px' }}>
67
99
  <header style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24, paddingBottom: 16, borderBottom: '1px solid #e2e8f0' }}>
@@ -75,7 +107,19 @@ export default function HomePage() {
75
107
  {isLoading ? (
76
108
  <span>Loading session...</span>
77
109
  ) : isAuthenticated ? (
78
- <UserMenu />
110
+ spaAuthed ? (
111
+ <UserMenu />
112
+ ) : (
113
+ <div style={{ display: 'inline-flex', alignItems: 'center', gap: 10 }}>
114
+ <span style={{ fontSize: 14, fontWeight: 500 }}>{displayIdentity}</span>
115
+ <a
116
+ href="/api/auth/logout"
117
+ style={{ padding: '6px 12px', borderRadius: 6, border: '1px solid #cbd5e1', background: '#fff', color: '#0f172a', textDecoration: 'none', fontSize: 13 }}
118
+ >
119
+ Sign out
120
+ </a>
121
+ </div>
122
+ )
79
123
  ) : (
80
124
  <div style={{ display: 'flex', gap: 10 }}>
81
125
  <SignInButton />
@@ -87,9 +131,9 @@ export default function HomePage() {
87
131
  </div>
88
132
  </header>
89
133
 
90
- {isAuthenticated && user && (
134
+ {isAuthenticated && activeUser && (
91
135
  <div style={{ background: '#ecfdf5', border: '1px solid #a7f3d0', padding: 12, borderRadius: 8, marginBottom: 20, fontSize: 14 }}>
92
- Signed in as <strong>{String(user.email || user.name || user.sub)}</strong>
136
+ Signed in as <strong>{displayIdentity}</strong>
93
137
  </div>
94
138
  )}
95
139
 
@@ -163,4 +207,3 @@ export default function HomePage() {
163
207
  </main>
164
208
  );
165
209
  }
166
-