fix(protocol): harden history response decoding

Share packet response validation across group and private history fetches so transport failures and empty responses cannot masquerade as empty pages.

Reject malformed group records and mismatched private-peer responses while preserving explicit QQ control-message filters. Mark fetched contexts as historical so old invite cards cannot overwrite live approval state.

Add wire-level regression coverage for failed responses, malformed entries, peer mismatches, ordering, and live-only identity observations. Refs #280.
This commit is contained in:
DrSmoothl committed 2026-07-25 23:43:30 +08:00
1 parent 5ad8027524
commit 95debcf34b
7 files changed
+204 -25

No files matched your search

@@ -0,0 +1,16 @@
import type { SendPacketResult } from '@snowluma/common/packet-sender';
export function requirePacketResponse(
result: SendPacketResult,
command: string,
): Uint8Array {
if (!result.success) {
throw new Error(
`${command} transport failed: ${result.errorMessage || 'unknown transport error'}`,
);
}
if (!result.gotResponse || !result.responseData || result.responseData.length === 0) {
throw new Error(`${command} response is empty`);
}
return result.responseData;
}