sns-login-sdk
Version:
统一身份登录 SDK - 基于自定义协议调用桌面应用程序进行身份认证
56 lines (47 loc) • 1.34 kB
TypeScript
export interface SnsLoginOptions {
/** 轮询超时时间(毫秒),默认10分钟 */
pollingTimeout?: number;
/** 轮询间隔(毫秒),默认1秒 */
pollingInterval?: number;
/** API基础URL */
baseURL?: string;
/** API端点配置 */
apiEndpoints?: {
getVp?: string;
};
/** 域名配置(用于桌面应用调用) */
baseUrl?: string;
/** 类型参数,默认值为1 */
type?: number;
}
export interface SnsLoginCallbacks {
/** 加载状态回调 */
onLoading?: (loading: boolean) => void;
/** 登录成功回调 */
onSuccess?: (token: string) => void;
/** 错误回调 */
onError?: (error: Error) => void;
/** 消息回调 */
onMessage?: (
message: string,
type?: 'info' | 'error' | 'warning' | 'success'
) => void;
}
export interface SnsLoginConfig {
/** SDK选项配置 */
options?: SnsLoginOptions;
/** 回调函数配置 */
callbacks?: SnsLoginCallbacks;
}
export declare class SnsLoginSDK {
constructor(config?: SnsLoginConfig);
/** 开始统一身份登录流程 */
login(): Promise<void>;
/** 停止轮询 */
stopPolling(): void;
/** 销毁SDK实例 */
destroy(): void;
}
/** 创建统一身份登录实例的工厂函数 */
export declare function createSnsLogin(config?: SnsLoginConfig): SnsLoginSDK;
export default SnsLoginSDK;