2025-01-14 00:54:30 +08:00
|
|
|
import { BaseController, Encryptor } from '@certd/lib-server';
|
|
|
|
|
import { OpenKey } from '../../modules/open/service/open-key-service.js';
|
|
|
|
|
|
|
|
|
|
export class BaseOpenController extends BaseController {
|
|
|
|
|
ok(res: any) {
|
|
|
|
|
const openKey: OpenKey = this.ctx.openKey;
|
|
|
|
|
if (openKey.encrypt) {
|
|
|
|
|
const data = JSON.stringify(res);
|
2025-01-15 01:26:23 +08:00
|
|
|
const encryptor = new Encryptor(openKey.keySecret, 'hex');
|
2025-01-14 00:54:30 +08:00
|
|
|
const encrypted = encryptor.encrypt(data);
|
|
|
|
|
return this.ok(encrypted);
|
|
|
|
|
}
|
2025-01-15 22:58:11 +08:00
|
|
|
return super.ok(res);
|
2025-01-14 00:54:30 +08:00
|
|
|
}
|
|
|
|
|
}
|