import { Request } from 'express'; import { UserProfile } from '../core/auth/user.entities'; import { KvDef } from '../core/kv/kv.helper'; import { WXJwtPayload } from './interfaces'; import { WeChatUser } from './wechat.entities'; import { MiniSubscribeData, SubscribeMessageInfo, TemplateData, WxQrTicketInfo, WxSendTemplateInfo } from './wx.interfaces'; import { WxUserInfo } from './wx.vo'; export interface WXTextMessage { ToUserName: string; FromUserName: string; CreateTime: number; MsgType: 'text'; Content: string; MsgId: string; } export interface WXSubscribeMessage { ToUserName: string; FromUserName: string; CreateTime: number; MsgType: 'event'; Event: 'subscribe' | 'unsubscribe'; EventKey: string; } export interface WXQrSceneMessage { ToUserName: string; FromUserName: string; CreateTime: number; MsgType: 'event'; Event: 'subscribe'; EventKey: string; Ticket: string; } export interface UserInfo { nickName: string; gender: number; language: string; city: string; province: string; country: string; avatarUrl: string; encryptedData: string; iv: string; } export declare enum WxTicketType { 'admin-login' = "admin-login" } export interface WXSubscribedQrSceneMessage { ToUserName: string; FromUserName: string; CreateTime: number; MsgType: 'event'; Event: 'SCAN'; EventKey: keyof typeof WxTicketType | string; Ticket: string; } export declare type WXEventMessage = WXSubscribeMessage | WXTextMessage | WXQrSceneMessage | WXSubscribedQrSceneMessage; export declare class WXEventMessageHelper { static isWXSubscribeMessage: (message: WXEventMessage) => boolean; static isWXTextMessage: (message: WXEventMessage) => boolean; static isWXSubscribedQrSceneMessage: (message: WXEventMessage) => boolean; } export declare class WeChatHelper { static noticeKvDef: KvDef; static checkSignature(opts: { signature: string; timestamp: string; nonce: string; }): Promise; static parseXmlToJson(req: Request): Promise; static getTicketByType(type: WxTicketType, value: string): Promise; static syncAdminUsers(): Promise; static syncAdminUser(openId: string): Promise; static handleEvent(message: WXSubscribeMessage | WXTextMessage | WXQrSceneMessage | WXSubscribedQrSceneMessage): Promise; static parseTemplateData(data: object, context: object): TemplateData; static handleAdminLogin(message: WXSubscribedQrSceneMessage): Promise; static updateAdmin(user: WeChatUser): Promise; static updateWeChatUserByUserInfo(userInfo: WxUserInfo): Promise; static updateWeChatUser(openId: string): Promise; static updateUserInfo(user: Pick, userInfo: UserInfo): Promise; static getSessionKey(payload: WXJwtPayload): Promise; static decryptData(key: string, encryptedData: string, iv: string): Promise; static updateUserPhoneNumber(payload: WXJwtPayload, user: UserProfile, body: { encryptedData: string; errMsg: string; iv: string; }): Promise; static code2Session(code: string): Promise; static getUserInfo(openId: string): Promise; static sendTemplateMsg({ openId, templateId, url, payload, }: { openId: string; templateId: string; url?: string; payload: TemplateData; }): Promise; static sendMiniSubscribeMsg({ openId, page, subscribeId, payload, }: { openId: string; page?: string; subscribeId: string; payload: MiniSubscribeData; }): Promise; }