feat(ui): implement OAuth login flow and dashboard components
CI / build-and-test (push) Failing after -32m0s

* Add OAuth login handling in app and UI components
* Create new components for login and dashboard pages
* Refactor sidebar and navigation structure
* Introduce types for access entries and status responses
This commit is contained in:
2026-04-26 09:12:46 +02:00
parent bdc78cc2a3
commit 71845d38d3
22 changed files with 1440 additions and 334 deletions
+5 -8
View File
@@ -1,4 +1,4 @@
import { GlobalStateStore } from '@warkypublic/svelix';
import { GlobalStateStore, isLoggedInStore } from '@warkypublic/svelix';
const normalizeApiURL = (url: string): string => url.replace(/\/+$/, '');
@@ -21,7 +21,7 @@ const resolveApiURL = (envURL?: string): string => {
return '';
};
export { GlobalStateStore };
export { GlobalStateStore, isLoggedInStore };
export type OAuthClientRegistration = {
client_id: string;
@@ -174,8 +174,8 @@ async function sha256(input: string): Promise<string> {
}
export async function fetchOAuthMetadata(): Promise<OAuthServerMetadata> {
const apiURL = ensureApiURL();
const response = await fetch(`${apiURL}/.well-known/oauth-authorization-server`);
const base = getPublicBaseURL();
const response = await fetch(`${base}/.well-known/oauth-authorization-server`);
if (!response.ok) {
throw new Error(`Failed to load OAuth metadata (${response.status})`);
}
@@ -185,10 +185,6 @@ export async function fetchOAuthMetadata(): Promise<OAuthServerMetadata> {
export async function ensureOAuthClientRegistration(metadata: OAuthServerMetadata): Promise<OAuthClientRegistration> {
const redirectURI = getOAuthRedirectURI();
const existing = readOAuthClient();
if (existing?.client_id && existing.redirect_uris?.includes(redirectURI)) {
return existing;
}
const response = await fetch(metadata.registration_endpoint, {
method: 'POST',
@@ -214,6 +210,7 @@ export async function ensureOAuthClientRegistration(metadata: OAuthServerMetadat
}
export async function buildOAuthAuthorizationURL(): Promise<string> {
removeStorage(OAUTH_CLIENT_KEY);
const metadata = await fetchOAuthMetadata();
const client = await ensureOAuthClientRegistration(metadata);
const codeVerifier = createRandomString(96);