system.ts 966 Bytes
// 签名规范 / 公钥下发(免签接口,规范 §2/§6)
// 继承 ApiClient,共享 http 与 RSA 加签/验签。
// 注意:登录相关的 LoginParams / LoginResult / login() 已由 ./auth 统一定义,
// 本模块仅保留签名规范(SignSpec)及 info/spec,避免同名类型在 api 桶导出时歧义。
import { ApiClient } from '../core/client';

export interface SignSpec {
  expireSeconds: number;
  nonceEnabled: boolean;
  appIds: string[];
  requestCanonicalRule: string;
  responseCanonicalRule: string;
  sample?: {
    requestCanonical: string;
    responseCanonical: string;
    responseCanonicalSign: string;
    serverPublicKey?: string;
  };
  serverPublicKey?: string;
  serverPublicKeyPem?: string;
}

class System extends ApiClient {
  info() {
    return this.get<Record<string, unknown>>('/system/auth/info');
  }

  spec() {
    return this.get<SignSpec>('/system/sign/spec');
  }
}

export const system = new System();