refactor: 完善版 P-2 前端分包与 P-3 揭示 userKey 加固
- admin vite 配置 manualChunks 拆分 naive/echarts/vendor,index chunk 从 1652KB 降到 69KB - 揭示 userKey 改为 POST 接口(写操作日志、防缓存)+ 前端二次确认,GET 仅返回掩码 - 更新问题清单待完善项状态与项目记忆
This commit is contained in:
@@ -56,7 +56,16 @@ export class SettingsController {
|
||||
@ApiBearerAuth()
|
||||
@Roles(RoleType.SUPER_ADMIN)
|
||||
@Get('tianhe/identity')
|
||||
@ApiOperation({ summary: '揭示天河链链上身份明文(userId/userKey/钱包地址),供管理员离线备份' })
|
||||
@ApiOperation({ summary: '读取天河链链上身份(userId + 钱包地址,userKey 掩码),用于设置页展示' })
|
||||
async getTianheIdentity() {
|
||||
const { userId, userKey, address } = await this.blockchain.revealTianheUserKey();
|
||||
return { userId, address, userKeyMasked: this.settingsService.maskSecretPublic(userKey) };
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@Roles(RoleType.SUPER_ADMIN)
|
||||
@Post('tianhe/identity/reveal')
|
||||
@ApiOperation({ summary: '揭示天河链 userKey 明文(供离线备份);用 POST 以便写入操作日志、避免缓存' })
|
||||
revealTianheIdentity() {
|
||||
return this.blockchain.revealTianheUserKey();
|
||||
}
|
||||
|
||||
@@ -127,6 +127,11 @@ export class SettingsService {
|
||||
return `${value.slice(0, 3)}******${value.slice(-3)}`;
|
||||
}
|
||||
|
||||
// 对外暴露的掩码工具(供控制器展示 userKey 掩码,不返回明文)
|
||||
maskSecretPublic(value: string): string {
|
||||
return this.maskSecret(value);
|
||||
}
|
||||
|
||||
isMaskedSecret(value?: string | null): boolean {
|
||||
return typeof value === 'string' && /^\*+$|^.{1,8}\*{3,}.{1,8}$/.test(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user