UNPKG

dnp-client

Version:

数据基础设施轻量连接器,帮助用户管理身份凭证、区域节点、业务节点,完成身份集成。

61 lines (51 loc) 1.52 kB
export interface DnpLoginOptions { /** 轮询超时时间(毫秒),默认10分钟 */ pollingTimeout?: number; /** 轮询间隔(毫秒),默认1秒 */ pollingInterval?: number; /** DNP服务器URL */ dnpServerUrl?: string; /** API端点配置 */ apiEndpoints?: { getVp?: string; }; /** 域名配置(用于桌面应用调用) */ baseUrl?: string; /** 类型参数,默认值为1 1-区域,2-业务 */ type?: number; /** 客户端类型 */ clientType?: "browser" | "electron" | "server"; } export interface DnpLoginCallbacks { /** 加载状态回调 */ onLoading?: (loading: boolean) => void; /** 登录成功回调 */ onSuccess?: (token: string) => void; /** 错误回调 */ onError?: (error: Error) => void; /** 消息回调 */ onMessage?: ( message: string, type?: "info" | "error" | "warning" | "success" ) => void; } export interface DnpLoginConfig { /** SDK选项配置 */ options?: DnpLoginOptions; /** 回调函数配置 */ callbacks?: DnpLoginCallbacks; } export declare class DNP { constructor(config?: DnpLoginConfig); /** 检测客户端类型 */ static detectClientType(): "browser" | "electron" | "server"; /** 开始统一身份登录流程 */ login(): Promise<void>; /** 停止轮询 */ stopPolling(): void; /** 销毁SDK实例 */ destroy(): void; } /** 创建DNP统一身份登录实例的工厂函数 */ export declare function createDnpLogin(config?: DnpLoginConfig): DNP; export default DNP;