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
|
|
@ -16,7 +16,7 @@
|
|||
// 한 액션에 여러 바인딩이 붙고, 여러 액션이 한 바인딩을 공유하기 때문이다.
|
||||
|
||||
import { TIMING } from './constants'
|
||||
import { bindingKey, isModifierKeyCode, normalizeBinding } from './keybinding'
|
||||
import { VK, bindingKey, isModifierKeyCode, normalizeBinding } from './keybinding'
|
||||
import type { BindingDevice, KeyBinding, KeyBindingActionId } from './keybinding'
|
||||
|
||||
// ============================================================
|
||||
|
|
@ -55,6 +55,18 @@ export interface ChordReleasedComponent {
|
|||
code: number
|
||||
}
|
||||
|
||||
/** keyDown 의 부가 정보 (어댑터가 관측한 눌림의 성격). */
|
||||
export interface ChordKeyDownOptions {
|
||||
/**
|
||||
* 이 눌림이 AltGr(가짜 LCtrl + RightAlt)이다 — AltGrPressDetector 판정.
|
||||
*
|
||||
* AltGr 배열(독일어·프랑스어·폴란드어·북유럽 등)에서 오른쪽 Alt 는 문자 입력(@, €, {, \)의
|
||||
* 시작이다. 바인딩 모양과 무관하게 이 누름으로 발동하는 트리거를 보류해, 이어서 문자 키가
|
||||
* 눌리면(noteKeyDown) 취소한다.
|
||||
*/
|
||||
altGr?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 시간 포트. 실제 구현은 Date.now / setTimeout, 테스트는 가짜 타이머를 넣는다.
|
||||
* schedule 은 취소 함수를 돌려준다 — 타이머 핸들 타입을 core 가 알 필요가 없다.
|
||||
|
|
@ -266,8 +278,23 @@ export class ChordStateMachine {
|
|||
|
||||
// ── 입력 ───────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 바인딩 여부와 무관하게 모든 키보드 눌림을 알린다 (keyDown 보다 먼저 호출).
|
||||
*
|
||||
* 비수정자 키가 눌렸다 = 보류 중인 AltGr 형태 트리거는 조합이나 문자 입력(AltGr+Q='@')의
|
||||
* 일부였다 → 취소한다. 바인딩된 키만 보면 바인딩되지 않은 문자 키가 보류를 끝내지 못해,
|
||||
* 문자 하나를 칠 때마다 보류 트리거가 발동한다.
|
||||
*
|
||||
* vk 가 null 이면 어댑터가 정본 좌표계로 옮기지 못한 키다. 수정자 키는 모두 옮길 수
|
||||
* 있으므로 비수정자로 본다. 수정자 키(가짜 LCtrl · Shift 추가 등)는 보류를 건드리지 않는다.
|
||||
*/
|
||||
noteKeyDown(vk: number | null): void {
|
||||
if (vk !== null && isModifierKeyCode(vk)) return
|
||||
this._cancelPendingExcept(null)
|
||||
}
|
||||
|
||||
/** 키/버튼 눌림. eventKey 는 이벤트의 bindingKey. */
|
||||
keyDown(eventKey: string): void {
|
||||
keyDown(eventKey: string, options: ChordKeyDownOptions = {}): void {
|
||||
const entries = this._byKey.get(eventKey)
|
||||
if (entries === undefined || entries.length === 0) return
|
||||
|
||||
|
|
@ -312,7 +339,7 @@ export class ChordStateMachine {
|
|||
|
||||
for (const trigger of triggers) {
|
||||
this._debug(`Key binding pressed: "${trigger.entry.actionId}" (double=${isDoublePress})`)
|
||||
if (trigger.entry.altGrShaped) {
|
||||
if (trigger.entry.altGrShaped || options.altGr === true) {
|
||||
this._deferPressed(trigger)
|
||||
} else {
|
||||
this._emitPressed(trigger)
|
||||
|
|
@ -393,13 +420,19 @@ export class ChordStateMachine {
|
|||
}, this._altGrGraceMs)
|
||||
}
|
||||
|
||||
private _cancelPendingExcept(eventKey: string): void {
|
||||
/** 보류 중인 트리거를 취소한다. eventKey 가 주어지면 그 바인딩의 보류는 남긴다. */
|
||||
private _cancelPendingExcept(eventKey: string | null): void {
|
||||
for (const trigger of this._pending) {
|
||||
if (trigger.key === eventKey) continue
|
||||
trigger.cancelTimer?.()
|
||||
trigger.cancelTimer = null
|
||||
trigger.status = 'cancelled'
|
||||
this._pending.delete(trigger)
|
||||
// 취소된 누름은 더블프레스의 첫 탭이 아니다 — '@' 를 치고 곧바로 오른쪽 Alt 를
|
||||
// 탭하면 hands-free 가 켜지는 일을 막는다.
|
||||
if (this._lastPress.get(trigger.key) === trigger.pressedAt) {
|
||||
this._lastPress.delete(trigger.key)
|
||||
}
|
||||
this._debug(`AltGr 형태 보류 트리거 취소 (다른 키가 이어짐): "${trigger.entry.actionId}"`)
|
||||
}
|
||||
}
|
||||
|
|
@ -434,3 +467,66 @@ export class ChordStateMachine {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// AltGr 눌림 판별 (Windows)
|
||||
// ============================================================
|
||||
|
||||
/**
|
||||
* Windows AltGr 판별기 (순수 정책).
|
||||
*
|
||||
* AltGr 배열에서 오른쪽 Alt 를 누르면 Windows 는 가짜 LCtrl 눌림을 먼저 보내고 곧바로
|
||||
* RAlt 눌림을 보낸다. 두 이벤트의 타임스탬프는 같다. 후킹 라이브러리(libuiohook)는 이 가짜
|
||||
* LCtrl 을 걸러내지 않고 Ctrl 수정자를 켜므로, RAlt 눌림이 `Ctrl+RightAlt` 로 보인다 —
|
||||
* 기본 'command' 바인딩과 겹치고 기본 'dictation'(RightAlt 단독)과는 절대 맞지 않는다.
|
||||
*
|
||||
* 판정: RAlt 눌림 직전 이벤트가 같은 타임스탬프의 LCtrl 눌림이고, 그 LCtrl 이 그 전까지
|
||||
* 놓여 있었다면 AltGr 다. 사용자가 LCtrl 을 먼저 누르고 있었다면(Ctrl+AltGr) 진짜 Ctrl 이다.
|
||||
* AltGr 를 누른 채 반복되는 RAlt 눌림(auto-repeat)도 같은 AltGr 로 본다.
|
||||
*
|
||||
* 후킹 이벤트에 스캔 코드(0x21D)·주입 플래그가 없어 타임스탬프로만 판별한다. 그래서 진짜
|
||||
* LCtrl 과 RAlt 를 같은 시계 틱 안에 함께 누르면 AltGr 로 오인할 수 있다 — 결과는 보류가
|
||||
* 붙은 RightAlt 단독 눌림이므로 안전한 쪽으로 틀린다.
|
||||
*/
|
||||
export class AltGrPressDetector {
|
||||
private _ctrlLeftDown = false
|
||||
private _altGrHeld = false
|
||||
/** 직전 키보드 눌림 (가짜 LCtrl 짝 판정용) */
|
||||
private _last: { vk: number | null; time: number; ctrlLeftWasDown: boolean } | null = null
|
||||
|
||||
/**
|
||||
* 키보드 눌림을 관측한다. 모든 눌림을 넣어야 한다(좌표계로 옮기지 못한 키는 vk=null).
|
||||
* 반환값: 이 눌림이 AltGr(가짜 LCtrl + RAlt)인가.
|
||||
*/
|
||||
keyDown(vk: number | null, time: number): boolean {
|
||||
const previous = this._last
|
||||
this._last = { vk, time, ctrlLeftWasDown: this._ctrlLeftDown }
|
||||
|
||||
if (vk === VK.CtrlLeft) {
|
||||
this._ctrlLeftDown = true
|
||||
return false
|
||||
}
|
||||
if (vk !== VK.AltRight) return false
|
||||
|
||||
if (this._altGrHeld) return true
|
||||
this._altGrHeld =
|
||||
previous !== null &&
|
||||
previous.vk === VK.CtrlLeft &&
|
||||
previous.time === time &&
|
||||
!previous.ctrlLeftWasDown
|
||||
return this._altGrHeld
|
||||
}
|
||||
|
||||
/** 키보드 놓임을 관측한다. */
|
||||
keyUp(vk: number | null): void {
|
||||
if (vk === VK.CtrlLeft) this._ctrlLeftDown = false
|
||||
if (vk === VK.AltRight) this._altGrHeld = false
|
||||
}
|
||||
|
||||
/** 모든 상태를 비운다 (후킹 중지 등). */
|
||||
reset(): void {
|
||||
this._ctrlLeftDown = false
|
||||
this._altGrHeld = false
|
||||
this._last = null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue