SnowLuma v2.4.2 source snapshot
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
This commit is contained in:
commit
fa9c73363d
1367 files changed
+355735
No files matched your search
@@ -0,0 +1,92 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
import { DeleteCustomFace } from '../../../src/oidb-services/custom-face/delete-custom-face';
|
||||
|
||||
function makeSender() {
|
||||
const resp: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.alloc(0),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => resp) };
|
||||
}
|
||||
|
||||
const SAMPLE_UIN = '2550419068';
|
||||
const SAMPLE_EMOJI_ID = '2550419068_0_0_0_2765030D118F8E04B1BFB8DC773C343B_0_0';
|
||||
|
||||
// Wire bytes captured from QQ 9.9.26-44343 (Faceroam.OpReq, opType=2, deleting
|
||||
// the emoji_id above).
|
||||
const DELETE_WIRE_HEX =
|
||||
'0a0e0801120a31302e302e323632303010fc9c91c00918022a370a35323535303431393036385f305f305f305f32373635303330443131384638453034423142464238444337373343333433425f305f30';
|
||||
|
||||
describe('DeleteCustomFace namespace', () => {
|
||||
describe('serialize + encode', () => {
|
||||
it('reproduces the captured delete wire bytes exactly', () => {
|
||||
const req = DeleteCustomFace.serialize({} as any, {
|
||||
uin: SAMPLE_UIN,
|
||||
emojiId: SAMPLE_EMOJI_ID,
|
||||
});
|
||||
const hex = Buffer.from(DeleteCustomFace.encode(req)).toString('hex');
|
||||
expect(hex).toBe(DELETE_WIRE_HEX);
|
||||
});
|
||||
|
||||
it('omits qqVersion from inner (delete inner is 14 bytes, not 28)', () => {
|
||||
const req = DeleteCustomFace.serialize({} as any, { uin: SAMPLE_UIN, emojiId: 'x' });
|
||||
expect(req.inner?.qqVersion).toBeUndefined();
|
||||
});
|
||||
|
||||
it('puts the emoji_id into field5.body.emojiId', () => {
|
||||
const req = DeleteCustomFace.serialize({} as any, {
|
||||
uin: SAMPLE_UIN,
|
||||
emojiId: SAMPLE_EMOJI_ID,
|
||||
});
|
||||
expect(req.body?.emojiId).toBe(SAMPLE_EMOJI_ID);
|
||||
});
|
||||
|
||||
it('uses field3=2 and leaves field6 unset', () => {
|
||||
const req = DeleteCustomFace.serialize({} as any, { uin: SAMPLE_UIN, emojiId: 'x' });
|
||||
expect(req.field3).toBe(2);
|
||||
expect(req.field6).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('invoke', () => {
|
||||
it('routes through "Faceroam.OpReq"', async () => {
|
||||
const sender = makeSender();
|
||||
await DeleteCustomFace.invoke(sender, { uin: SAMPLE_UIN, emojiId: SAMPLE_EMOJI_ID });
|
||||
expect(sender.sendRawPacket.mock.calls[0]![0]).toBe('Faceroam.OpReq');
|
||||
});
|
||||
|
||||
it('passes the captured wire body', async () => {
|
||||
const sender = makeSender();
|
||||
await DeleteCustomFace.invoke(sender, { uin: SAMPLE_UIN, emojiId: SAMPLE_EMOJI_ID });
|
||||
const [, body] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(Buffer.from(body as Uint8Array).toString('hex')).toBe(DELETE_WIRE_HEX);
|
||||
});
|
||||
|
||||
it('resolves on success without returning a body', async () => {
|
||||
const sender = makeSender();
|
||||
await expect(
|
||||
DeleteCustomFace.invoke(sender, { uin: SAMPLE_UIN, emojiId: 'x' }),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('throws when the sender reports no response', async () => {
|
||||
const sender = {
|
||||
sendRawPacket: vi.fn(async (): Promise<SendPacketResult> => ({
|
||||
success: false,
|
||||
gotResponse: false,
|
||||
errorCode: 0,
|
||||
errorMessage: 'timeout',
|
||||
responseData: null,
|
||||
})),
|
||||
};
|
||||
await expect(
|
||||
DeleteCustomFace.invoke(sender, { uin: SAMPLE_UIN, emojiId: 'x' }),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
CustomFaceModifyResp,
|
||||
CustomFaceMoveBody,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
|
||||
import { FetchCustomFaceDetail } from '../../../src/oidb-services/custom-face/fetch-custom-face-detail';
|
||||
|
||||
const EMOJI_A_ID = '2550419068_0_0_0_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_0_0';
|
||||
const EMOJI_A_MD5 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
|
||||
const EMOJI_B_ID = '2550419068_0_0_0_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB_0_0';
|
||||
const EMOJI_B_MD5 = 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB';
|
||||
|
||||
function makeSender(body: CustomFaceModifyResp) {
|
||||
const r: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.from(protobuf_encode<OidbBase<CustomFaceModifyResp>>({ body })),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
}
|
||||
|
||||
describe('FetchCustomFaceDetail namespace', () => {
|
||||
it('sends the IDA-confirmed 0x902e_1 opType=2 request with every id and md5', async () => {
|
||||
const sender = makeSender({ retCode: 0, entries: [] });
|
||||
await FetchCustomFaceDetail.invoke(sender, {
|
||||
emojis: [
|
||||
{ emojiId: EMOJI_A_ID, md5: EMOJI_A_MD5 },
|
||||
{ emojiId: EMOJI_B_ID, md5: EMOJI_B_MD5 },
|
||||
],
|
||||
});
|
||||
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0x902e_1');
|
||||
const env = protobuf_decode<OidbBase<CustomFaceMoveBody>>(bytes);
|
||||
expect(env.command).toBe(0x902e);
|
||||
expect(env.subCommand).toBe(1);
|
||||
expect(env.reserved).toBe(1);
|
||||
expect(env.body).toMatchObject({
|
||||
field1: 1,
|
||||
opType: 2,
|
||||
emojis: [
|
||||
{ emojiId: EMOJI_A_ID, md5: EMOJI_A_MD5 },
|
||||
{ emojiId: EMOJI_B_ID, md5: EMOJI_B_MD5 },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('returns tag 3 descriptions and falls back to legacy tag 2', async () => {
|
||||
const sender = makeSender({
|
||||
retCode: 0,
|
||||
entries: [
|
||||
{ emoji: { emojiId: EMOJI_A_ID }, legacyDesc: '旧版描述' },
|
||||
{ emoji: { emojiId: EMOJI_B_ID }, legacyDesc: '旧值', desc: '新版描述' },
|
||||
],
|
||||
});
|
||||
|
||||
await expect(
|
||||
FetchCustomFaceDetail.invoke(sender, {
|
||||
emojis: [{ emojiId: EMOJI_A_ID, md5: EMOJI_A_MD5 }],
|
||||
}),
|
||||
).resolves.toEqual([
|
||||
{ emojiId: EMOJI_A_ID, desc: '旧版描述' },
|
||||
{ emojiId: EMOJI_B_ID, desc: '新版描述' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not silently accept malformed or duplicate response entries', () => {
|
||||
expect(() =>
|
||||
FetchCustomFaceDetail.deserialize({} as any, {
|
||||
entries: [{ desc: 'missing id' }],
|
||||
}),
|
||||
).toThrow(/has no emoji id/);
|
||||
|
||||
expect(() =>
|
||||
FetchCustomFaceDetail.deserialize({} as any, {
|
||||
entries: [{ emoji: { emojiId: EMOJI_A_ID } }, { emoji: { emojiId: EMOJI_A_ID } }],
|
||||
}),
|
||||
).toThrow(/duplicate emoji id/);
|
||||
});
|
||||
|
||||
it('surfaces a non-zero business result', () => {
|
||||
expect(() =>
|
||||
FetchCustomFaceDetail.deserialize({} as any, {
|
||||
retCode: 5,
|
||||
errMsg: 'denied',
|
||||
}),
|
||||
).toThrow(/denied/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
import type { FaceroamOpReq, FaceroamOpResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
|
||||
import { FetchCustomFaceList } from '../../../src/oidb-services/custom-face/fetch-custom-face-list';
|
||||
|
||||
const SAMPLE_UIN = '10001';
|
||||
const EMOJI_A = '10001_0_0_0_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_0_0';
|
||||
const EMOJI_B = '10001_0_0_0_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB_0_0';
|
||||
|
||||
function encodeLegacyList(uin: string): Uint8Array {
|
||||
return protobuf_encode<FaceroamOpReq>({
|
||||
inner: { field1: 1, osVersion: '10.0.26200', qqVersion: '9.9.28-46928' },
|
||||
uin: BigInt(uin),
|
||||
field3: 1,
|
||||
field6: 1,
|
||||
});
|
||||
}
|
||||
|
||||
function makeSender(
|
||||
opts: {
|
||||
faces?: FaceroamOpResp;
|
||||
success?: boolean;
|
||||
gotResponse?: boolean;
|
||||
errorMessage?: string;
|
||||
responseData?: Uint8Array | null;
|
||||
} = {},
|
||||
) {
|
||||
const result: SendPacketResult = {
|
||||
success: opts.success ?? true,
|
||||
gotResponse: opts.gotResponse ?? true,
|
||||
errorCode: 0,
|
||||
errorMessage: opts.errorMessage ?? '',
|
||||
responseData:
|
||||
opts.responseData !== undefined
|
||||
? opts.responseData
|
||||
: Buffer.from(
|
||||
protobuf_encode<FaceroamOpResp>(
|
||||
opts.faces ?? { retCode: 0, item: { faceIds: [EMOJI_A, EMOJI_B] } },
|
||||
),
|
||||
),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => result) };
|
||||
}
|
||||
|
||||
describe('FetchCustomFaceList namespace', () => {
|
||||
describe('serialize + encode', () => {
|
||||
it('keeps the list request bytes the ProfileApi fetch already sent', () => {
|
||||
const req = FetchCustomFaceList.serialize({} as any, { uin: SAMPLE_UIN });
|
||||
const hex = Buffer.from(FetchCustomFaceList.encode(req)).toString('hex');
|
||||
expect(hex).toBe(Buffer.from(encodeLegacyList(SAMPLE_UIN)).toString('hex'));
|
||||
});
|
||||
|
||||
it('sends qqVersion on inner and sets field3=1 / field6=1', () => {
|
||||
const req = FetchCustomFaceList.serialize({} as any, { uin: SAMPLE_UIN });
|
||||
expect(req.inner?.qqVersion).toBe('9.9.28-46928');
|
||||
expect(req.inner?.osVersion).toBe('10.0.26200');
|
||||
expect(req.field3).toBe(1);
|
||||
expect(req.field6).toBe(1);
|
||||
expect(req.body).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('invoke', () => {
|
||||
it('routes through "Faceroam.OpReq" and returns the id list', async () => {
|
||||
const sender = makeSender();
|
||||
await expect(FetchCustomFaceList.invoke(sender, { uin: SAMPLE_UIN })).resolves.toEqual([
|
||||
EMOJI_A,
|
||||
EMOJI_B,
|
||||
]);
|
||||
expect(sender.sendRawPacket.mock.calls[0]![0]).toBe('Faceroam.OpReq');
|
||||
const [, body] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(Buffer.from(body as Uint8Array).toString('hex')).toBe(
|
||||
Buffer.from(encodeLegacyList(SAMPLE_UIN)).toString('hex'),
|
||||
);
|
||||
});
|
||||
|
||||
it('returns an empty list when the item is missing', async () => {
|
||||
const sender = makeSender({ faces: { retCode: 0 } });
|
||||
await expect(FetchCustomFaceList.invoke(sender, { uin: SAMPLE_UIN })).resolves.toEqual(
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
it('throws when the sender reports no response', async () => {
|
||||
const sender = makeSender({
|
||||
success: false,
|
||||
gotResponse: false,
|
||||
errorMessage: 'timeout',
|
||||
responseData: null,
|
||||
});
|
||||
await expect(FetchCustomFaceList.invoke(sender, { uin: SAMPLE_UIN })).rejects.toThrow(
|
||||
/timeout/,
|
||||
);
|
||||
});
|
||||
|
||||
it('throws when the Faceroam retCode is non-zero', async () => {
|
||||
const sender = makeSender({ faces: { retCode: 1, message: 'denied' } });
|
||||
await expect(FetchCustomFaceList.invoke(sender, { uin: SAMPLE_UIN })).rejects.toThrow(
|
||||
/fetch custom face error: denied/,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_decode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { CustomFaceModifyBody } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
import { ModifyCustomFace } from '../../../src/oidb-services/custom-face/modify-custom-face';
|
||||
|
||||
const SAMPLE_EMOJI_ID = '2550419068_0_0_0_ABCDEF0123456789ABCDEF0123456789_0_0';
|
||||
const SAMPLE_MD5 = 'ABCDEF0123456789ABCDEF0123456789';
|
||||
|
||||
// Independent byte-oracle: hand-decoded from the proto layout (NOT re-derived
|
||||
// from the encoder), so a field-number change goes red. Cross-checked against
|
||||
// the 9.9.26-44343 frida capture (cmd 0x902e_1, opType 3):
|
||||
// 08 aea002 f1 command = 0x902e
|
||||
// 10 01 f2 subCommand = 1
|
||||
// 22 73 f4 body (115B):
|
||||
// 08 01 f1 = 1
|
||||
// 12 0a "10.0.26200" f2 osVersion
|
||||
// 18 03 f3 opType = 3
|
||||
// 2a 5f f5 entry (95B):
|
||||
// 0a 59 f1 emoji (89B):
|
||||
// 0a 35 <emoji_id> f1
|
||||
// 12 20 <md5> f2
|
||||
// 12 02 "hi" f2 desc
|
||||
// 60 01 f12 = 1
|
||||
const MODIFY_WIRE_HEX =
|
||||
'08aea002100122730801120a31302e302e323632303018032a5f0a590a35323535303431393036385f305f305f305f41424344454630313233343536373839414243444546303132333435363738395f305f3012204142434445463031323334353637383941424344454630313233343536373839120268696001';
|
||||
|
||||
function makeSender() {
|
||||
const r: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.alloc(0),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
}
|
||||
|
||||
describe('ModifyCustomFace namespace', () => {
|
||||
it('declares command 0x902e sub 1', () => {
|
||||
expect(ModifyCustomFace.command).toBe(0x902e);
|
||||
expect(ModifyCustomFace.subCommand).toBe(1);
|
||||
});
|
||||
|
||||
it('serializes opType=3 with emoji {emojiId,md5} + desc in f5.entry, f12=1', () => {
|
||||
const out = ModifyCustomFace.serialize({} as any, {
|
||||
emojiId: SAMPLE_EMOJI_ID,
|
||||
md5: SAMPLE_MD5,
|
||||
desc: 'hi',
|
||||
});
|
||||
expect(out.opType).toBe(3);
|
||||
expect(out.entry?.emoji).toMatchObject({ emojiId: SAMPLE_EMOJI_ID, md5: SAMPLE_MD5 });
|
||||
expect(out.entry?.desc).toBe('hi');
|
||||
expect(out.field12).toBe(1);
|
||||
});
|
||||
|
||||
it('routes to OidbSvcTrpcTcp.0x902e_1 and encodes the exact wire bytes', async () => {
|
||||
const sender = makeSender();
|
||||
await ModifyCustomFace.invoke(sender, {
|
||||
emojiId: SAMPLE_EMOJI_ID,
|
||||
md5: SAMPLE_MD5,
|
||||
desc: 'hi',
|
||||
});
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0x902e_1');
|
||||
expect(Buffer.from(bytes as Uint8Array).toString('hex')).toBe(MODIFY_WIRE_HEX);
|
||||
// Structure decodes back.
|
||||
const env = protobuf_decode<OidbBase<CustomFaceModifyBody>>(bytes as Uint8Array);
|
||||
expect(env.command).toBe(0x902e);
|
||||
expect(env.body?.opType).toBe(3);
|
||||
expect(env.body?.entry?.desc).toBe('hi');
|
||||
});
|
||||
|
||||
it('resolves on success (retCode 0 / empty body)', async () => {
|
||||
const sender = makeSender();
|
||||
await expect(
|
||||
ModifyCustomFace.invoke(sender, {
|
||||
emojiId: SAMPLE_EMOJI_ID,
|
||||
md5: SAMPLE_MD5,
|
||||
desc: '',
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('throws when the business body carries a non-zero retCode', () => {
|
||||
expect(() =>
|
||||
ModifyCustomFace.deserialize({} as any, { retCode: 5, errMsg: 'bad' }),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_decode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { CustomFaceMoveBody } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
import { MoveCustomFace } from '../../../src/oidb-services/custom-face/move-custom-face';
|
||||
|
||||
const EMOJI_A_ID = '2550419068_0_0_0_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_0_0';
|
||||
const EMOJI_A_MD5 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
|
||||
const EMOJI_B_ID = '2550419068_0_0_0_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB_0_0';
|
||||
const EMOJI_B_MD5 = 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB';
|
||||
|
||||
// Byte-oracle hand-decoded from the proto layout. Cross-checked against the
|
||||
// 9.9.26-44343 frida capture (fav25/fav27 ENC#3, the "upload new order" step
|
||||
// of the two-step move — step 2, must be preceded by OrderCustomFace 0x902f):
|
||||
// 08 aea002 f1 command = 0x902e ← move step 2: 0x902e opType=2
|
||||
// 10 01 f2 subCommand = 1
|
||||
// 22 <len> f4 body:
|
||||
// 08 01 f1 = 1
|
||||
// 12 0a "10.0.26200" f2 osVersion
|
||||
// 18 02 f3 opType = 2 ← move upload
|
||||
// 22 59 <emoji A> f4 repeated: {0a 35 emojiId, 12 20 md5}
|
||||
// 22 59 <emoji B> f4 repeated
|
||||
// 60 01 f12 = 1 ← envelope reserved (uinForm=true); without it the
|
||||
// server accepts the request but does NOT reorder.
|
||||
const MOVE_WIRE_HEX =
|
||||
'08aea002100122c6010801120a31302e302e3236323030180222590a35323535303431393036385f305f305f305f41414141414141414141414141414141414141414141414141414141414141415f305f301220414141414141414141414141414141414141414141414141414141414141414122590a35323535303431393036385f305f305f305f42424242424242424242424242424242424242424242424242424242424242425f305f30122042424242424242424242424242424242424242424242424242424242424242426001';
|
||||
|
||||
function makeSender() {
|
||||
const r: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.alloc(0),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
}
|
||||
|
||||
describe('MoveCustomFace namespace', () => {
|
||||
it('declares command 0x902e sub 1 with uinForm (envelope reserved=1)', () => {
|
||||
expect(MoveCustomFace.command).toBe(0x902e);
|
||||
expect(MoveCustomFace.subCommand).toBe(1);
|
||||
expect(MoveCustomFace.uinForm).toBe(true);
|
||||
});
|
||||
|
||||
it('serializes opType=2 with the emoji list in f4 (repeated, in order)', () => {
|
||||
const out = MoveCustomFace.serialize({} as any, {
|
||||
emojis: [
|
||||
{ emojiId: EMOJI_A_ID, md5: EMOJI_A_MD5 },
|
||||
{ emojiId: EMOJI_B_ID, md5: EMOJI_B_MD5 },
|
||||
],
|
||||
});
|
||||
expect(out.opType).toBe(2);
|
||||
expect(out.emojis?.map((e) => e.emojiId)).toEqual([EMOJI_A_ID, EMOJI_B_ID]);
|
||||
});
|
||||
|
||||
it('routes to OidbSvcTrpcTcp.0x902e_1 and encodes the exact wire bytes (incl. envelope f12)', async () => {
|
||||
const sender = makeSender();
|
||||
await MoveCustomFace.invoke(sender, {
|
||||
emojis: [
|
||||
{ emojiId: EMOJI_A_ID, md5: EMOJI_A_MD5 },
|
||||
{ emojiId: EMOJI_B_ID, md5: EMOJI_B_MD5 },
|
||||
],
|
||||
});
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0x902e_1');
|
||||
expect(Buffer.from(bytes as Uint8Array).toString('hex')).toBe(MOVE_WIRE_HEX);
|
||||
const env = protobuf_decode<OidbBase<CustomFaceMoveBody>>(bytes as Uint8Array);
|
||||
expect(env.command).toBe(0x902e);
|
||||
expect(env.reserved).toBe(1);
|
||||
expect(env.body?.opType).toBe(2);
|
||||
expect(env.body?.emojis?.map((e) => e.emojiId)).toEqual([EMOJI_A_ID, EMOJI_B_ID]);
|
||||
});
|
||||
|
||||
it('resolves on success (retCode 0 / empty body)', async () => {
|
||||
const sender = makeSender();
|
||||
await expect(
|
||||
MoveCustomFace.invoke(sender, { emojis: [{ emojiId: EMOJI_A_ID, md5: EMOJI_A_MD5 }] }),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('throws when the business body carries a non-zero retCode', () => {
|
||||
expect(() =>
|
||||
MoveCustomFace.deserialize({} as any, { retCode: 5, errMsg: 'bad' }),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_decode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { CustomFaceOrderBody } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
import { OrderCustomFace } from '../../../src/oidb-services/custom-face/order-custom-face';
|
||||
|
||||
const SAMPLE_EMOJI_ID = '2550419068_0_0_0_3BC06CE836D6134326EA2C1B37BF1584_0_0';
|
||||
|
||||
// Byte-oracle taken DIRECTLY from the 9.9.26-44343 frida capture (fav27/fav28
|
||||
// ENC#2, the real "move to front" instruction — the first of the two-step move).
|
||||
//
|
||||
// 08 afa002 f1 command = 0x902f ← move instruction cmd
|
||||
// 10 01 f2 subCommand = 1
|
||||
// 22 52 f4 body (82B):
|
||||
// 0a 17 f1 env (23B):
|
||||
// 08 8008 f1 = 1024 (client type flag)
|
||||
// 12 0a "10.0.26200" f2 osVersion
|
||||
// 1a 06 "9.9.26" f3 buildVersion (short)
|
||||
// 12 35 <emoji_id> f2 emojiId
|
||||
// 18 01 f3 position = 1 (front)
|
||||
// 60 01 f12 = 1 ← envelope reserved (uinForm)
|
||||
const ORDER_WIRE_HEX =
|
||||
'08afa002100122520a17088008120a31302e302e32363230301a06392e392e32361235323535303431393036385f305f305f305f33424330364345383336443631333433323645413243314233374246313538345f305f3018016001';
|
||||
|
||||
function makeSender() {
|
||||
const r: SendPacketResult = {
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData: Buffer.alloc(0),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
}
|
||||
|
||||
describe('OrderCustomFace namespace', () => {
|
||||
it('declares command 0x902f sub 1 with uinForm (envelope reserved=1)', () => {
|
||||
expect(OrderCustomFace.command).toBe(0x902f);
|
||||
expect(OrderCustomFace.subCommand).toBe(1);
|
||||
expect(OrderCustomFace.uinForm).toBe(true);
|
||||
});
|
||||
|
||||
it('serializes env{1024, osVersion, "9.9.26"} + emojiId + position', () => {
|
||||
const out = OrderCustomFace.serialize({} as any, { emojiId: SAMPLE_EMOJI_ID, position: 1 });
|
||||
expect(out.env).toMatchObject({
|
||||
field1: 1024,
|
||||
osVersion: '10.0.26200',
|
||||
buildVersion: '9.9.26',
|
||||
});
|
||||
expect(out.emojiId).toBe(SAMPLE_EMOJI_ID);
|
||||
expect(out.position).toBe(1);
|
||||
});
|
||||
|
||||
it('routes to OidbSvcTrpcTcp.0x902f_1 and reproduces the captured wire exactly', async () => {
|
||||
const sender = makeSender();
|
||||
await OrderCustomFace.invoke(sender, { emojiId: SAMPLE_EMOJI_ID, position: 1 });
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0x902f_1');
|
||||
expect(Buffer.from(bytes as Uint8Array).toString('hex')).toBe(ORDER_WIRE_HEX);
|
||||
const env = protobuf_decode<OidbBase<CustomFaceOrderBody>>(bytes as Uint8Array);
|
||||
expect(env.command).toBe(0x902f);
|
||||
expect(env.reserved).toBe(1);
|
||||
expect(env.body?.emojiId).toBe(SAMPLE_EMOJI_ID);
|
||||
expect(env.body?.position).toBe(1);
|
||||
});
|
||||
|
||||
it('resolves on success (retCode 0 / empty body)', async () => {
|
||||
const sender = makeSender();
|
||||
await expect(
|
||||
OrderCustomFace.invoke(sender, { emojiId: SAMPLE_EMOJI_ID, position: 1 }),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('throws when the business body carries a non-zero retCode', () => {
|
||||
expect(() =>
|
||||
OrderCustomFace.deserialize({} as any, { retCode: 5, errMsg: 'bad' }),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user