/// import { ExtendOptions } from 'got'; import { WeChatPaymentAPIConfig } from './config'; export interface GlobalAccessTokenResult { access_token: string; refresh_token?: string; expires_in?: number; } /** * Generate digest hash based on the content * @param {string} content content to be digested * @param {string=} algorithm digest algorithm, default 'sha1' * @return {string} */ export declare function genHash(content: string, algorithm: string): string; /** * Generate SHA1 hash */ export declare function genSHA1(content: string): string; /** * Generate MD5 hash */ export declare function genMD5(content: string): string; export declare function genHmacSHA256(content: string, key: string): string; /** * Parse the object to query string without encoding based on the ascii key order * @param {object} args search params in object * @param {boolean} noLowerCase * @return {string} */ export declare function paramsToString(args: Record, noLowerCase?: boolean): string; /** * Send the request to wechat server * @param {string} url * @param {object} options custom request options */ export declare function sendWechatRequest(url: string, options: ExtendOptions): Promise>; /** * Send the payment request to wechat server * @param {string} url * @param {object} options custom request options */ export declare function sendWechatPaymentRequest(url: string, options: ExtendOptions): Promise; /** * Create nonce string * @return {string} */ export declare function nonceStr(): string; /** * Create timestamp string to seconds */ export declare function timestamp(): string; /** * Check if date is expired * @param {Date|string} modifyDate * @param {number=} interval milliseconds custom expires in * @return {boolean} */ export declare function isExpired(modifyDate: Date | string, interval?: number): boolean; /** * Get global access token from wechat server * @param {string} appId * @param {string} appSecret * @param {string} accessTokenUrl */ export declare function getGlobalAccessToken(appId: string, appSecret: string, accessTokenUrl: string): Promise; /** * Parse the xml data returned from wechat server * @return {Promise} result promise */ export declare function parseXML(xmlData: string): Promise>; /** * Build xml data string from the JSON object * @param {object} objData - object to xml string * @return {Promise} */ export declare function buildXML(objData: Record): Promise; /** * Simple Date formatter * @param {(string|Date)=} date * @param {string=} format * @return {string} */ export declare function simpleDate(date?: string | Date, format?: string): string; /** * Add "/sandboxnew" for payment apis to for testing * @param paymentUrls */ export declare function paymentUrlsWithSandBox(paymentUrls: WeChatPaymentAPIConfig): WeChatPaymentAPIConfig; export declare function createBuffer(str: string, encoding?: BufferEncoding): Buffer; export declare function createBufferFromBase64(base64Str: string): Buffer;