export interface ProjectNode { id: string; fullPath: string; avatarUrl: string; group: { id: string; name: string; avatarUrl: string }; repository: { rootRef: string }; } export interface GetProjectNodeResponse { projects: ProjectNode[]; } /** * Patterns that indicate an authentication failure (invalid / expired token). * Shared across UI packages so that VersionsSidebar and code-mode sagas stay in sync. */ export const GIT_AUTH_ERROR_PATTERNS: readonly string[] = [ 'authentication failed', 'could not read username', 'invalid credentials', 'invalid username or token', 'bad credentials', 'password authentication is not supported', '401' ]; /** * Patterns that indicate insufficient token permissions (not auth failure). * Shared across UI packages so that VersionsSidebar and code-mode sagas stay in sync. */ export const GIT_PERMISSION_ERROR_PATTERNS: readonly string[] = [ 'denied to', 'permission to', 'the requested url returned error: 403', "doesn't have write access", 'contents: write', 'insufficient permissions', 'resource not accessible', 'does not have sufficient permissions', 'does not have write access', '"contents" permission' ]; /** * Returns true if the error message matches any known git auth error pattern. */ export function isGitAuthErrorMessage(error: unknown): boolean { const message = error instanceof Error ? error.message : String(error ?? ''); const lower = message.toLowerCase(); return GIT_AUTH_ERROR_PATTERNS.some((pattern) => lower.includes(pattern)); } /** * Returns true if the error message matches any known git permission error pattern. */ export function isGitPermissionErrorMessage(error: unknown): boolean { const message = error instanceof Error ? error.message : String(error ?? ''); const lower = message.toLowerCase(); return GIT_PERMISSION_ERROR_PATTERNS.some((pattern) => lower.includes(pattern)); }