Revert "fix: add requiresApiKey to register, unregister, merge_groups, update_trace_profile_group"

This reverts commit f23124a157.
This commit is contained in:
2026-11-01 14:40:58 +08:00
parent 09b6ca6fc8
commit 2ba21dabc2

View File

@@ -150,7 +150,7 @@ export class ApiError extends Error {
async function httpCall(cmd: string, args: Record<string, any>, retries = 3): Promise<any> { async function httpCall(cmd: string, args: Record<string, any>, retries = 3): Promise<any> {
const base = getApiBase() const base = getApiBase()
const { url, method, body, timeout: requestTimeout, requiresAdminToken, requiresApiKey } = buildHttpRequest(cmd, args) const { url, method, body, timeout: requestTimeout, requiresAdminToken } = buildHttpRequest(cmd, args)
const fullUrl = url.startsWith('http://') || url.startsWith('https://') ? url : `${base}${url}` const fullUrl = url.startsWith('http://') || url.startsWith('https://') ? url : `${base}${url}`
// Get admin token from localStorage if needed // Get admin token from localStorage if needed
@@ -167,14 +167,6 @@ async function httpCall(cmd: string, args: Record<string, any>, retries = 3): Pr
} }
} }
// Add API key if needed
if (requiresApiKey) {
const apiKey = localStorage.getItem('momentry_api_key') || 'muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69'
if (apiKey) {
headers['x-api-key'] = apiKey
}
}
const controller = new AbortController() const controller = new AbortController()
const timeout = setTimeout(() => controller.abort(), requestTimeout ?? DEFAULT_TIMEOUT) const timeout = setTimeout(() => controller.abort(), requestTimeout ?? DEFAULT_TIMEOUT)
@@ -260,7 +252,7 @@ async function httpCall(cmd: string, args: Record<string, any>, retries = 3): Pr
} }
} }
function buildHttpRequest(cmd: string, args: Record<string, any>): { url: string; method: string; body?: any; timeout?: number; requiresAdminToken?: boolean; requiresApiKey?: boolean } { function buildHttpRequest(cmd: string, args: Record<string, any>): { url: string; method: string; body?: any; timeout?: number; requiresAdminToken?: boolean } {
const a = args const a = args
switch (cmd) { switch (cmd) {
@@ -467,8 +459,7 @@ case 'search_keyword': {
file_uuid: a.fileUuid, file_uuid: a.fileUuid,
source_groups: a.sourceGroups, source_groups: a.sourceGroups,
target_group_name: a.targetGroupName target_group_name: a.targetGroupName
}, }
requiresApiKey: true
} }
} }
case 'bind_face': { case 'bind_face': {
@@ -552,7 +543,7 @@ case 'search_keyword': {
return { url: '/api/v1/jobs', method: 'POST', body: {} } return { url: '/api/v1/jobs', method: 'POST', body: {} }
} }
case 'register_file': { case 'register_file': {
return { url: '/api/v1/files/register', method: 'POST', body: { file_path: a.filePath }, requiresApiKey: true } return { url: '/api/v1/files/register', method: 'POST', body: { file_path: a.filePath } }
} }
case 'get_command_status': { case 'get_command_status': {
return { url: `/api/v1/command/${a.commandId}`, method: 'GET' } return { url: `/api/v1/command/${a.commandId}`, method: 'GET' }
@@ -580,7 +571,7 @@ case 'search_keyword': {
return { url: `/api/v1/file/${a.fileUuid}/face-groups/similar?${params.toString()}`, method: 'GET' } return { url: `/api/v1/file/${a.fileUuid}/face-groups/similar?${params.toString()}`, method: 'GET' }
} }
case 'update_trace_profile_group': { case 'update_trace_profile_group': {
return { url: '/api/v1/trace-profile/group', method: 'PUT', body: { file_uuid: a.fileUuid, trace_ids: a.traceIds, name: a.name, key_frame: a.keyFrame, key_face: a.keyFace }, requiresApiKey: true } return { url: '/api/v1/trace-profile/group', method: 'PUT', body: { file_uuid: a.fileUuid, trace_ids: a.traceIds, name: a.name, key_frame: a.keyFrame, key_face: a.keyFace } }
} }
case 'get_file_profile': { case 'get_file_profile': {
return { url: `/api/v1/file-profile?file_uuid=${a.fileUuid}`, method: 'GET' } return { url: `/api/v1/file-profile?file_uuid=${a.fileUuid}`, method: 'GET' }
@@ -605,7 +596,7 @@ case 'search_keyword': {
case 'unregister_file': { case 'unregister_file': {
const body: any = { file_uuid: a.fileUuid } const body: any = { file_uuid: a.fileUuid }
if (a.deleteOutputFiles != null) body.delete_output_files = a.deleteOutputFiles if (a.deleteOutputFiles != null) body.delete_output_files = a.deleteOutputFiles
return { url: '/api/v1/unregister', method: 'POST', body, timeout: UNREGISTER_TIMEOUT, requiresApiKey: true } return { url: '/api/v1/unregister', method: 'POST', body, timeout: UNREGISTER_TIMEOUT }
} }
case 'ingest_file': { case 'ingest_file': {
return { url: `/api/v1/file/${a.fileUuid}/checkin`, method: 'POST' } return { url: `/api/v1/file/${a.fileUuid}/checkin`, method: 'POST' }