import { WeChat } from 'node-socialite/dist/Providers/WeChat'; import ConfigInterface from '../Core/Contracts/ConfigInterface'; import Encryptor from '../Core/Encryptor'; import AccessTokenAwareClient from '../Core/HttpClient/AccessTokenAwareClient'; import CacheMixin from '../Core/Mixins/CacheMixin'; import ClientMixin from '../Core/Mixins/ClientMixin'; import ConfigMixin from '../Core/Mixins/ConfigMixin'; import HttpClientMixin from '../Core/Mixins/HttpClientMixin'; import ServerRequestMixin from '../Core/Mixins/ServerRequestMixin'; import OfficialAccountApplication from '../OfficialAccount/Application'; import MiniAppApplication from './Authorizer/MiniApp/Application'; import { OpenPlatformConfig, OfficialAccountConfig, OfficialAccountOAuthFactory, MiniAppConfig } from '../Types/global'; import AccountInterface from './Contracts/AccountInterface'; import ApplicationInterface from './Contracts/ApplicationInterface'; import Server from './Server'; import AccessTokenInterface from '../Core/Contracts/AccessTokenInterface'; import VerifyTicketInterface from './Contracts/VerifyTicketInterface'; import Authorization from './Authorization'; import AuthorizerAccessToken from './AuthorizerAccessToken'; /** * 开放平台应用 */ declare class Application implements ApplicationInterface { constructor(config: ConfigInterface | OpenPlatformConfig); protected account: AccountInterface; protected encryptor: Encryptor; protected server: Server; protected componentAccessToken: AccessTokenInterface; protected verifyTicket: VerifyTicketInterface; getAccount(): AccountInterface; /** * 设置当前账户实例 * @param account * @returns */ setAccount(account: AccountInterface): this; getVerifyTicket(): VerifyTicketInterface; setVerifyTicket(verifyTicket: VerifyTicketInterface): this; getEncryptor(): Encryptor; /** * 设置加密机实例 * @param encryptor * @returns */ setEncryptor(encryptor: Encryptor): this; getServer(): Server; /** * 设置服务端实例 * @param server * @returns */ setServer(server: Server): this; getAccessToken(): AccessTokenInterface; getComponentAccessToken(): AccessTokenInterface; /** * 设置AccessToken实例 * @param accessToken * @returns */ setComponentAccessToken(componentAccessToken: AccessTokenInterface): this; /** * 使用授权码获取授权信息 * @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/authorization_info.html * @param authorizationCode * @returns */ getAuthorization(authorizationCode: string): Promise; /** * 获取/刷新接口调用令牌 * @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html * @param authorizerAppId * @param authorizerRefreshToken * @returns */ refreshAuthorizerToken(authorizerAppId: string, authorizerRefreshToken: string): Promise; /** * 获取预授权码 * @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/pre_auth_code.html * @returns */ createPreAuthorizationCode(): Promise<{ /** * 错误代码 */ errcode?: string; /** * 错误信息 */ errmsg?: string; /** * 预授权码 */ pre_auth_code?: string; /** * 有效期,单位:秒 */ expires_in?: number; }>; /** * 生成授权页地址 * @param callbackUrl 授权后的回调地址 * @param optional 预授权码,不传 * @returns */ createPreAuthorizationUrl(callbackUrl: string, optional?: string | { pre_auth_code: string; }): Promise; getOAuth(): WeChat; /** * 根据刷新令牌获取公众号实例 * @param appId * @param refreshToken * @param config * @returns */ getOfficialAccountWithRefreshToken(appId: string, refreshToken: string, config?: ConfigInterface | OfficialAccountConfig): Promise; /** * 根据访问令牌获取公众号实例 * @param appId * @param accessToken * @param config * @returns */ getOfficialAccountWithAccessToken(appId: string, accessToken: string, config?: ConfigInterface | OfficialAccountConfig): OfficialAccountApplication; /** * 获取公众号实例 * @param authorizerAccessToken * @param config * @returns */ getOfficialAccount(authorizerAccessToken: AuthorizerAccessToken, config?: ConfigInterface | OfficialAccountConfig): OfficialAccountApplication; /** * 创建第三方oauth工厂 * @param authorizerAppId * @param config * @returns */ protected createAuthorizerOAuthFactory(authorizerAppId: string, config: ConfigInterface): OfficialAccountOAuthFactory; /** * 根据刷新令牌获取小程序实例 * @param appId * @param refreshToken * @param config * @returns */ getMiniAppWithRefreshToken(appId: string, refreshToken: string, config?: ConfigInterface | MiniAppConfig): Promise; /** * 根据访问令牌获取小程序实例 * @param appId * @param accessToken * @param config * @returns */ getMiniAppWithAccessToken(appId: string, accessToken: string, config?: ConfigInterface | MiniAppConfig): MiniAppApplication; /** * 获取小程序实例 * @param authorizerAccessToken * @param config * @returns */ getMiniApp(authorizerAccessToken: AuthorizerAccessToken, config?: ConfigInterface | MiniAppConfig): MiniAppApplication; /** * 获取第三方授权令牌 * @param appId * @param refreshToken * @returns */ getAuthorizerAccessToken(appId: string, refreshToken: string): Promise; createClient(): AccessTokenAwareClient; /** * 获取请求默认配置 * @returns */ protected getHttpClientDefaultOptions(): Record; } interface Application extends ConfigMixin, CacheMixin, ClientMixin, ServerRequestMixin, HttpClientMixin { } export = Application;