import Store, { StoreGlobalTokenItem, StoreUrlSignatureItem } from './store/Store'; import { WeChatOptions } from './WeChatOptions'; import { GlobalAccessTokenResult } from './utils'; /** * JSSDK related functionality * @return {JSSDK} JSSDK instance */ declare class JSSDK { refreshedTimes: number; options: WeChatOptions; store: Store; constructor(options?: WeChatOptions); /** * Check if token is expired starting from the modify date * @param modifyDate * @static * @return {boolean} */ static isTokenExpired(modifyDate: string | Date): boolean; /** * Create NonceStr before generating the signature * @static * @return {string} */ static createNonceStr(): string; /** * Filter the signature for the client * @param {object} originalSignatureObj original signature information * @return filtered signature object */ filterSignature(originalSignatureObj: StoreUrlSignatureItem): StoreUrlSignatureItem; /** * Remove hash from the url, wechat signature does not need it * @param {string} url original url * @static * @return {string} */ static normalizeUrl(url: string): string; /** * Generate the url signature with the provided info * @param {string} url current url * @param {string} accessToken * @param {string} ticket js ticket * @static * @returns generated wechat signature info */ static generateSignature(url: string, accessToken: string, ticket: string): StoreUrlSignatureItem; /** * Need to verify before you are a wechat developer * @param {object} query url query sent by the wechat server to do the validation * @return {boolean} */ verifySignature(query: Record): boolean; /** * Send request to get wechat access token * @return {Promise} */ getAccessToken(): Promise; /** * Get wechat ticket with the accessToken * @param {string} accessToken token received from the @see getAccessToken above * @return {Promise} */ getJsApiTicket(accessToken: string): Promise<{ ticket: string; }>; /** * Update the global token or js_ticket, we should cache this to prevent requesting too often * @param {string} token * @param {string} ticket * @return {Promise} resolved with the updated globalToken object */ updateAccessTokenOrTicketGlobally(token: string, ticket: string): Promise; /** * Get new access token and ticket from wechat server, and update that to cache * @param {boolean=} force force update, by default it will only get at most 5 times within 2 hours, * cause the wechat server limits the access_token requests number * @return {Promise} */ getGlobalTokenAndTicket(force: boolean): Promise; /** * Get or generate global token info for signature generating process * @return {Promise} */ prepareGlobalToken(): Promise; /** * Save or update the signature * @param {object} info signature information to save * @return {Promise} */ saveSignature(info: StoreUrlSignatureItem): Promise; /** * Update the signature for existing url * @param {string} url signature of url need to update * @param {object} info update info need to be updated to the existing url signature info * @return {Promise} */ updateSignature(url: string, info: StoreUrlSignatureItem): Promise; /** * Get the signature from cache or create a new one * @param {string} url * @param {boolean=} forceNewSignature if true, generate a new signature rather than getting from cache * @return {Promise} */ getSignature(url: string, forceNewSignature?: boolean): Promise; /** * Create a new signature now, and save to store * @param {string} url signature will be created for the url * @return {Promise} resolved with filtered signature results */ createSignature(url: string): Promise; /** * Just get url signature from cache * @param {string} url * @return {Promise} filtered signature info */ getCachedSignature(url: string): Promise; } export default JSSDK;