import Store, { StoreOAuthItem } from './store/Store'; import { WeChatOptions } from './WeChatOptions'; /** * OAuth class * @return {OAuth} OAuth instance */ declare class OAuth { options: WeChatOptions; oAuthUrl: string; store: Store; snsUserInfoUrl: string; snsUserBaseUrl: string; constructor(options?: WeChatOptions); /** * Get wechat user profile based on the access token * @param {object} tokenInfo access token info received based on the code(passed by the wechat server to the redirect_uri) * @param {boolean=} withToken if true, the access token info will be merged to the resolved user profile object * @return {Promise} */ getUserInfoRemotely(tokenInfo: StoreOAuthItem, withToken: boolean): Promise; /** * Set the expire time starting from now for the cached access token * @param {object} tokenInfo * @static * @return {object} tokenInfo updated token info */ static setAccessTokenExpirationTime(tokenInfo: StoreOAuthItem): StoreOAuthItem; /** * Generate redirect url for use wechat oauth page * @param {string} redirectUrl * @param {string=} scope pass custom scope * @param {string=} state pass custom state * @return {string} generated oauth uri */ generateOAuthUrl(redirectUrl: string, scope?: string, state?: string): string; /** * Get wechat user base info, aka, get openid and token * @param {*} code code included in the redirect url * @param {string} [key] key to store the oauth token * @return {Promise} */ getUserBaseInfo(code: string, key: string): Promise; /** * Get wechat user info, including nickname, openid, avatar, etc... * @param {*} code * @param {string} [key] key to store oauth token * @param {boolean} [withToken] return token info together with the profile * @return {Promise} */ getUserInfo(code: string, key: string, withToken: boolean): Promise; /** * Get oauth access token * @param {*} code * @param {string} key custom user session id to identify cached token * @return {Promise} */ getAccessToken(code: string, key: string): Promise; /** * Get access token from wechat server * @param {*} code * @param {string} key * @return {Promise} */ getAccessTokenRemotely(code: string, key: string): Promise; /** * Refresh access token with the cached refresh_token over the wechat server * @param {string} key * @param {object} tokenInfo * @return {Promise} */ refreshAccessToken(key: string, tokenInfo: StoreOAuthItem): Promise; /** * Check if cached token is valid over the wechat server * @param {object} tokenInfo * @return {Promise} */ isAccessTokenValid(tokenInfo: StoreOAuthItem): Promise>; /** * Set default wechat oauth url for the instance */ setDefaultOAuthUrl(): void; /** * Check if cached token is expired * @param {object} tokenInfo * @return {boolean} */ static isAccessTokenExpired(tokenInfo: StoreOAuthItem): boolean; } export default OAuth;