feat: 客户页面改为站内查看存证和证书

This commit is contained in:
Nixevol
2026-11-15 12:15:04 +08:00
parent 6669722c00
commit 2955efb278
15 changed files with 253 additions and 70 deletions
@@ -14,6 +14,26 @@ export function depositSignature(path: string, query: Record<string, unknown>, b
return createHash('sha256').update(json + timestamp + key, 'utf8').digest('hex');
}
export interface StoredCertificateView {
text: string;
digest: string;
txHash: string;
author: string;
createdAt: string | null;
}
/** 公开页面只接收存证字段。天河链证书网址留在服务端,不进入浏览器。 */
export function presentStoredCertificate(value: unknown, environment: DepositEnvironment, address: string, text: string, mode: string | null, artist?: string | null): StoredCertificateView | null {
if (!safeCertificateUrl(value, environment, address) || !text.trim()) return null;
const params = new URLSearchParams(new URL(String(value)).hash.slice('#/certificate?'.length));
const digest = params.get('digest') || '';
const txHash = params.get('txHash') || '';
const rawTime = params.get('createTime');
const created = rawTime && /^\d+$/.test(rawTime) ? new Date(Number(rawTime)) : null;
const author = mode === 'ARTWORK_ARTIST' && artist?.trim() ? artist.trim() : address;
return { text, digest, txHash, author, createdAt: created && !Number.isNaN(created.getTime()) ? created.toISOString() : null };
}
export function safeCertificateUrl(value: unknown, environment: DepositEnvironment, address?: string): string | null {
if (typeof value !== 'string') return null;
try {