fix: red-team round 3 hardening across desktop, mobile, core and server
Batch of red-team r3 fixes that were in the working tree before the 2026-09-28 design overhaul, committed as one unit with their tests. - desktop main: STT timeouts and sidecar, voice recording store, sync (credentials, audio, knowledge reindex, push gates), runtime provisioner, update policy, AltGr keybindings, voice-command policy, dictionary file codec/limits, meeting transcript condensing and a local recording ledger so interrupted-session recovery only closes meetings this device recorded (a phone's live meeting is left alone). - mobile: login CSRF via implicit token callbacks rejected, account deletion/retention, durable queue retention, knowledge realtime without unfiltered DELETE, meeting re-record failure paths, cloud STT client, preferences store/resync. - core: text chunking splits long unbroken transcripts to fit, template field policy, dictionary limits, meeting markdown inline handling. - server: payple webhook policy and cancellation order scope, meeting document generation quota, team RPC null-role guard, unified LLM quota in-flight accounting, knowledge chunk vector index, meeting re-record failure paths (migrations 20260929*). - ci: portable/runtime feed gates, update-policy schema, Forgejo file delete and alias planning. Four older tests are updated to the new contracts rather than the old behavior: token-pair auth callbacks are rejected, knowledge realtime no longer subscribes to DELETE, long transcript lines are split, and meeting recovery requires the local recording ledger for empty rows.
This commit is contained in:
parent
2428ede03d
commit
ba9ef9741e
161 changed files with 17056 additions and 2379 deletions
|
|
@ -2,6 +2,7 @@ import type { RealtimeChannel } from '@supabase/supabase-js'
|
|||
import type { Meeting, Team, TeamRole } from '@d3ro/api-client'
|
||||
import { PUBLIC_SITE_ORIGIN, SITE_URLS } from '@d3ro/core/web-urls'
|
||||
import { supabase } from '../../lib/supabase'
|
||||
import { invokeEdgeFunction, type EdgeFunctionFailure } from '../../lib/edge-functions'
|
||||
|
||||
export interface TeamSummary extends Team {
|
||||
role: TeamRole
|
||||
|
|
@ -407,23 +408,26 @@ async function invokeRpc(name: string, params: Record<string, unknown>): Promise
|
|||
}
|
||||
}
|
||||
|
||||
async function readFunctionFailure(error: unknown): Promise<TeamServiceError> {
|
||||
const context = (error as { context?: unknown })?.context
|
||||
if (context instanceof Response) {
|
||||
try {
|
||||
const payload: unknown = await context.clone().json()
|
||||
if (isRecord(payload)) {
|
||||
const code = typeof payload.error === 'string' ? payload.error : ''
|
||||
const message = typeof payload.message === 'string'
|
||||
? payload.message
|
||||
: code || `Team function returned ${context.status}`
|
||||
return toTeamServiceError({ code, message })
|
||||
}
|
||||
} catch {
|
||||
return toTeamServiceError({ message: `Team function returned ${context.status}` })
|
||||
/**
|
||||
* Team Edge Functions put the machine code in `error` and a human string in
|
||||
* `message`. The transport decoding lives in lib/edge-functions; this keeps
|
||||
* only the team-specific field selection and fallbacks.
|
||||
*/
|
||||
function readFunctionFailure(failure: EdgeFunctionFailure): TeamServiceError {
|
||||
if (failure.status !== null && failure.body !== null) {
|
||||
if (!failure.body.readable) {
|
||||
return toTeamServiceError({ message: `Team function returned ${failure.status}` })
|
||||
}
|
||||
const payload = failure.body.payload
|
||||
if (isRecord(payload)) {
|
||||
const code = typeof payload.error === 'string' ? payload.error : ''
|
||||
const message = typeof payload.message === 'string'
|
||||
? payload.message
|
||||
: code || `Team function returned ${failure.status}`
|
||||
return toTeamServiceError({ code, message })
|
||||
}
|
||||
}
|
||||
return toTeamServiceError(error)
|
||||
return toTeamServiceError(failure.cause)
|
||||
}
|
||||
|
||||
export async function listTeams(userId: string): Promise<TeamSummary[]> {
|
||||
|
|
@ -705,10 +709,9 @@ export async function createTeamInvite(
|
|||
throw new TeamServiceError('validation', 'Invite role is invalid')
|
||||
}
|
||||
try {
|
||||
const { data, error } = await supabase.functions.invoke('team-invite', {
|
||||
body: { team_id: teamId, email, role },
|
||||
})
|
||||
if (error !== null) throw await readFunctionFailure(error)
|
||||
const result = await invokeEdgeFunction('team-invite', { team_id: teamId, email, role })
|
||||
if (!result.ok) throw readFunctionFailure(result)
|
||||
const data = result.data
|
||||
if (!isRecord(data)) {
|
||||
throw new TeamServiceError('invalid-response', 'Invite response is not an object')
|
||||
}
|
||||
|
|
@ -746,10 +749,9 @@ export async function cancelTeamInvite(teamId: string, inviteId: string): Promis
|
|||
export async function acceptTeamInvite(tokenValue: string): Promise<TeamAcceptResult> {
|
||||
const token = normalizeInviteToken(tokenValue)
|
||||
try {
|
||||
const { data, error } = await supabase.functions.invoke('team-accept', {
|
||||
body: { token },
|
||||
})
|
||||
if (error !== null) throw await readFunctionFailure(error)
|
||||
const result = await invokeEdgeFunction('team-accept', { token })
|
||||
if (!result.ok) throw readFunctionFailure(result)
|
||||
const data = result.data
|
||||
if (!isRecord(data)) {
|
||||
throw new TeamServiceError('invalid-response', 'Accept response is not an object')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue