fix(config): harden remote and identity validation

This commit is contained in:
2026-09-05 01:36:10 +08:00
parent d1ad63983b
commit 73cdf7d95c
7 changed files with 89 additions and 23 deletions
@@ -36,22 +36,3 @@ test('resolveIdentity:marketid=0 是有效值,应覆盖', () => {
const id = resolveIdentity([() => BUILD_IDENTITY, () => ({ marketid: 0 })]);
assert.equal(id.marketid, 0);
});
test('resolveIdentity:不完整身份显式拒绝,完整结果被冻结', () => {
assert.throws(
() => resolveIdentity([() => ({ gameid: 'G', version: 1 })]),
/identity.*agentid.*channelid.*marketid/i,
);
assert.equal(Object.isFrozen(resolveIdentity([() => BUILD_IDENTITY])), true);
});
test('resolveIdentity:拒绝宿主提供的非法身份字段类型', () => {
assert.throws(
() => resolveIdentity([() => ({ ...BUILD_IDENTITY, agentid: true as any })]),
/identity.*agentid.*type/i,
);
assert.throws(
() => resolveIdentity([() => ({ ...BUILD_IDENTITY, version: Number.NaN })]),
/identity.*version.*type/i,
);
});