system.ts 1.01 KB
// 签名规范 / 公钥下发(免签接口,规范 §2/§6)
// 继承 ApiClient,共享 http 与 RSA 加签/验签。
import { ApiClient } from '../core/client';
import type { LoginSession } from '../../access/session';

export interface LoginParams {
  account: string;
  password: string;
}

export type LoginResult = LoginSession;

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 {
  login(data: LoginParams) {
    return this.post<LoginResult>('/system/auth/login', data);
  }

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

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

export const system = new System();