feat(protocol): modify/move custom face via OIDB 0x902e + 0x902f (#110)

modify(改备注)走 OIDB 0x902e_1 opType=3 单包;move(移动排序)走
0x902f_1 移动指令 + 0x902e_1 opType=2 上传新顺序两步流程。两者均带
envelope f12=1(uinForm),实测持久化(跨 QQ 重启保持)。

- proto-defs: CustomFaceModifyBody/Resp、CustomFaceOrderBody、CustomFaceMoveBody
- protocol: ModifyCustomFace、OrderCustomFace、MoveCustomFace 三个 namespace + wire byte-oracle 测试
- core: ProfileApi 加 modifyCustomFace / moveCustomFace(move 内部 fetch + 两步发包)
- onebot: modify_custom_face、move_custom_face action
This commit is contained in:
Qiao authored and GitHub committed 2026-06-19 15:47:43 +08:00
1 parent 258b7e1e72
commit d38a0a4c1b
12 files changed
+1110 -8

No files matched your search

@@ -0,0 +1,64 @@
// OIDB 0x902e_1 opType=3 — 修改收藏表情(custom face)备注。
//
// modify 和 move 共用 cmd 0x902e,靠业务体 f3 的 opType 区分(modify=3)。
// 走 OIDB 通道(OidbSvcTrpcTcp.0x902e_1),不是 Faceroam.OpReq——fetch/delete
// 走 Faceroam,modify/move 走 OIDB,是抓包确认的两条不同通道。
//
// 业务体(OIDB 信封 f4 内):
// { f1:1, f2:osVersion, f3:3, f5:{ f1:{emojiId,md5}, f2:desc }, f12:1 }
// f5.entry.emoji 是 {emojiId, md5},desc 是新备注。f12=1 是修改标志。
// emojiId 格式 `<uin>_0_0_0_<MD5>_0_0`,md5 是 32 位大写 hex,均来自 fetch。
//
// 响应 f4 repeated 返回受影响条目 {f1:{emojiId,md5}, f3:desc}(含改后 desc),
// 成功只看 retCode=0。字段编号严格对齐 9.9.26-44343 frida 抓包。
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type {
CustomFaceModifyBody,
CustomFaceModifyResp,
} from '@snowluma/proto-defs/oidb-actions/base';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { CLIENT_VERSION } from './shared';
export namespace ModifyCustomFace {
export const command = 0x902e;
export const subCommand = 1;
export interface Params {
/** 形如 `<UIN>_0_0_0_<MD5>_0_0`,来自 fetch 响应。 */
emojiId: string;
/** 32 位大写 hex MD5,emoji_id 中段。 */
md5: string;
/** 新备注(可为空字符串清空备注)。 */
desc: string;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): CustomFaceModifyBody => ({
field1: 1,
osVersion: CLIENT_VERSION,
opType: 3,
entry: {
emoji: { emojiId: p.emojiId, md5: p.md5 },
desc: p.desc,
},
field12: 1,
});
export const deserialize = (_ctx: Deps, body: CustomFaceModifyResp): void => {
if (body.retCode && body.retCode !== 0) {
throw new Error(`modify custom face error: ${body.errMsg || body.retCode}`);
}
};
export const encode = (env: OidbBase<CustomFaceModifyBody>): Uint8Array =>
protobuf_encode<OidbBase<CustomFaceModifyBody>>(env);
export const decode = (bytes: Uint8Array): OidbBase<CustomFaceModifyResp> =>
protobuf_decode<OidbBase<CustomFaceModifyResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, ModifyCustomFace, params);
}
@@ -0,0 +1,63 @@
// OIDB 0x902e_1 opType=2 — 收藏表情(custom face)排序上传(move 第2步)。
//
// "移动到最前"两步流程的第2步:把新顺序的完整 emoji 列表上传,第一个就是
// 移到最前的。第1步是 OrderCustomFace(0x902f 移动指令)。必须先发 0x902f
// 再发本包——单发本包不生效(服务端无移动指令上下文)。
//
// modify(opType=3)和 move(opType=2)共用 cmd 0x902e,区分在业务体 f3。
// envelope 带 f12=1(reserved=1,uinForm)。业务体(OIDB 信封 f4 内):
// { f1:1, f2:osVersion, f3:2, f4:[repeated {emojiId, md5}] }
// f4 是完整排序后的列表,用 fetch 顺序把目标挪到第一即可(不需要 DB 显示顺序)。
// 字段编号严格对齐 QQ 9.9.26-44343 抓包。
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type {
CustomFaceModifyResp,
CustomFaceMoveBody,
} from '@snowluma/proto-defs/oidb-actions/base';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { CLIENT_VERSION } from './shared';
export namespace MoveCustomFace {
export const command = 0x902e;
export const subCommand = 1;
/** envelope reserved=1(UIN-form),抓包见信封 f12=1。不发则服务端不改顺序。 */
export const uinForm = true;
export interface EmojiItem {
/** 形如 `<UIN>_0_0_0_<MD5>_0_0`,来自 fetch 响应。 */
emojiId: string;
/** 32 位大写 hex MD5,emoji_id 中段。 */
md5: string;
}
export interface Params {
/** 完整且有序的 emoji 列表,整表上传。 */
emojis: EmojiItem[];
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): CustomFaceMoveBody => ({
field1: 1,
osVersion: CLIENT_VERSION,
opType: 2,
emojis: p.emojis.map((e) => ({ emojiId: e.emojiId, md5: e.md5 })),
});
export const deserialize = (_ctx: Deps, body: CustomFaceModifyResp): void => {
if (body.retCode && body.retCode !== 0) {
throw new Error(`move custom face error: ${body.errMsg || body.retCode}`);
}
};
export const encode = (env: OidbBase<CustomFaceMoveBody>): Uint8Array =>
protobuf_encode<OidbBase<CustomFaceMoveBody>>(env);
export const decode = (bytes: Uint8Array): OidbBase<CustomFaceModifyResp> =>
protobuf_decode<OidbBase<CustomFaceModifyResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, MoveCustomFace, params);
}
@@ -0,0 +1,59 @@
// OIDB 0x902f_1 — 收藏表情(custom face)移动指令(move 第1步)。
//
// "移动到最前"两步流程的第1步:发 0x902f 指明目标 emoji + 目标位置。
// 第2步是 MoveCustomFace(0x902e opType=2 上传新顺序列表)。单发本包不生效,
// 必须配合第2步。envelope 带 f12=1(uinForm)。
//
// 业务体(OIDB 信封 f4 内):
// { f1:{f1:1024, f2:osVersion, f3:buildVersion}, f2:emojiId, f3:position }
// f1 是客户端环境(1024 是 client type 标志),f2 要移动的 emoji_id,
// f3 目标位置(1=最前)。字段编号对齐 9.9.26-44343 frida 抓包。
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type {
CustomFaceModifyResp,
CustomFaceOrderBody,
} from '@snowluma/proto-defs/oidb-actions/base';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { CLIENT_VERSION } from './shared';
// build 版本简写:抓包见 f1.f3 = "9.9.26"(去掉 build 号后缀)。
const BUILD_VERSION_SHORT = '9.9.26';
export namespace OrderCustomFace {
export const command = 0x902f;
export const subCommand = 1;
/** envelope reserved=1(UIN-form),抓包见信封 f12=1。 */
export const uinForm = true;
export interface Params {
/** 形如 `<UIN>_0_0_0_<MD5>_0_0`,来自 fetch 响应。 */
emojiId: string;
/** 目标位置(从 1 开始,1=最前)。 */
position: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): CustomFaceOrderBody => ({
env: { field1: 1024, osVersion: CLIENT_VERSION, buildVersion: BUILD_VERSION_SHORT },
emojiId: p.emojiId,
position: p.position,
});
export const deserialize = (_ctx: Deps, body: CustomFaceModifyResp): void => {
if (body.retCode && body.retCode !== 0) {
throw new Error(`order custom face error: ${body.errMsg || body.retCode}`);
}
};
export const encode = (env: OidbBase<CustomFaceOrderBody>): Uint8Array =>
protobuf_encode<OidbBase<CustomFaceOrderBody>>(env);
export const decode = (bytes: Uint8Array): OidbBase<CustomFaceModifyResp> =>
protobuf_decode<OidbBase<CustomFaceModifyResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, OrderCustomFace, params);
}
@@ -11,9 +11,10 @@ import type { FaceroamOpReqInner } from '@snowluma/proto-defs/oidb-actions/base'
export const FACEROAM_SERVICE = 'Faceroam.OpReq';
// 客户端版本标识。直接硬编码抓包看到的值——QQ 不同小版本之间这部分
// 理论上会变,但 Faceroam 服务端对版本号并不敏感,先按当前目标版本写死,
// 理论上会变,但服务端对版本号并不敏感,先按当前目标版本写死,
// 真出问题再从 identity 里取。
const CLIENT_VERSION = '10.0.26200';
/** osVersion 字符串,Faceroam inner 与 0x902e 业务体 f2 共用。 */
export const CLIENT_VERSION = '10.0.26200';
const CLIENT_BUILD = '9.9.26-44343';
/**