This commit is contained in:
Your Name
2026-07-08 15:10:29 +00:00
parent d63ed3e7ef
commit 8f0f0cd36e
22 changed files with 1129 additions and 1032 deletions
+45 -1
View File
@@ -1,5 +1,6 @@
import { useState, useEffect } from 'react'
import { getAuthStatus, getAuthKey, signIn } from '../services/api'
import type { RequestError } from '../services/api'
import { isCadesPluginAvailable, listCertificates, signWithCadesPlugin } from '../services/cadesplugin'
import type { CertInfo } from '../services/cadesplugin'
@@ -14,6 +15,8 @@ export function AuthPage({ onAuth }: Props) {
const [selectedThumbprint, setSelectedThumbprint] = useState('')
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [errorDebug, setErrorDebug] = useState<string | null>(null)
const [debugExpanded, setDebugExpanded] = useState(false)
useEffect(() => {
getAuthStatus().then(setStatus).catch(() => {})
@@ -34,6 +37,8 @@ export function AuthPage({ onAuth }: Props) {
async function handleSignIn() {
setLoading(true)
setError('')
setErrorDebug(null)
setDebugExpanded(false)
try {
const { uuid, data } = await getAuthKey()
const signature = await signWithCadesPlugin(data, selectedThumbprint || undefined)
@@ -42,7 +47,11 @@ export function AuthPage({ onAuth }: Props) {
setStatus(s)
if (s.authenticated) onAuth()
} catch (err) {
setError(String(err instanceof Error ? err.message : err))
const re = err as RequestError
setError(re.message)
if (re.debugInfo) {
setErrorDebug(JSON.stringify(re.debugInfo, null, 2))
}
} finally {
setLoading(false)
}
@@ -120,6 +129,41 @@ export function AuthPage({ onAuth }: Props) {
{error && (
<div style={{ color: '#c62828', fontSize: 14, marginTop: 8 }}>Ошибка: {error}</div>
)}
{errorDebug && (
<div style={{ marginTop: 12 }}>
<button
onClick={() => setDebugExpanded(!debugExpanded)}
style={{
background: 'transparent',
border: '1px solid #b0bec5',
borderRadius: 4,
padding: '6px 12px',
cursor: 'pointer',
fontSize: 13,
color: '#37474f',
}}
>
{debugExpanded ? '▼ Скрыть лог запроса к API маркировки' : '▶ Показать лог запроса к API маркировки'}
</button>
{debugExpanded && (
<pre style={{
marginTop: 8,
padding: 12,
background: '#263238',
color: '#e0e0e0',
borderRadius: 6,
fontSize: 12,
lineHeight: 1.5,
overflowX: 'auto',
whiteSpace: 'pre-wrap',
wordBreak: 'break-all',
}}>
{errorDebug}
</pre>
)}
</div>
)}
</div>
<div style={{ marginTop: 24, fontSize: 13, color: '#666' }}>