feat: support real browser auth import

This commit is contained in:
liumangmang
2026-06-02 13:51:29 +08:00
parent f4d16a4c01
commit 84148f4a69
22 changed files with 1651 additions and 111 deletions
+19
View File
@@ -491,6 +491,12 @@ export interface AuthCaptureSession {
ws_url: string
}
export interface BrowserImportSession {
session_id: string
secret: string
expires_in_seconds: number
}
export interface AuthCaptureCandidate {
type: 'bearer_token' | 'cookie' | 'cookie_bundle' | 'credential' | 'api_key'
source: string
@@ -513,6 +519,13 @@ export interface AuthCaptureResult {
candidates: AuthCaptureCandidate[]
}
export interface BrowserImportStatus {
session_id: string
ready: boolean
expires_at: number
result: AuthCaptureResult | null
}
export const authCaptureApi = {
createSession: (url: string, width?: number, height?: number) =>
api.post<AuthCaptureSession>('/api/auth-capture/sessions', { url, width, height }),
@@ -522,6 +535,12 @@ export const authCaptureApi = {
}),
closeSession: (sessionId: string) =>
api.delete(`/api/auth-capture/sessions/${sessionId}`),
createImportSession: (targetUrl: string) =>
api.post<BrowserImportSession>('/api/auth-capture/import-sessions', { target_url: targetUrl }),
importSessionStatus: (sessionId: string, options?: { includeRaw?: boolean }) =>
api.get<BrowserImportStatus>(`/api/auth-capture/import-sessions/${sessionId}`, {
params: options?.includeRaw ? { include_raw: true } : undefined,
}),
wsUrl: (sessionId: string, token?: string) => {
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:'
const params = new URLSearchParams()