// # Source: https://github.com/smallfawn/QLScriptPublic/blob/main/wxapp/wcs.js // # Raw: https://raw.githubusercontent.com/smallfawn/QLScriptPublic/main/wxapp/wcs.js // # Repo: smallfawn/QLScriptPublic // # Path: wxapp/wcs.js // # UploadedAt: 2026-05-14T07:10:35Z // # SHA256: d9b348cac05cc8da8c9155c9b46a421f1ba392f2982930f6f89d7636709ee6d5 // # Category: 微信小程序/抓包版 // # Evidence: appid/openid/session_key/encryptedData等小程序字段 // const axios = require("axios"); class WeChatCodeServer { constructor(options) { this.serverUrl = options.url; this.appid = options.appid; this.auth = options.auth; } getCode(openid) { console.log('等待获取code:'); return new Promise((resolve, reject) => { axios.post(this.serverUrl + '/wx/code', { appid: this.appid, openid }, { headers: { 'auth': this.auth }, timeout: 30 * 1000 }).then(res => { console.log('获取code成功:'); resolve(res); }).catch(err => { reject(err); }); }); } cloudInit(openid) { console.log('等待云函数初始化:'); return new Promise((resolve, reject) => { axios.post(this.serverUrl + '/wx/call/init', { appid: this.appid, openid }, { headers: { 'auth': this.auth }, timeout: 30 * 1000 }).then(res => { console.log('云函数初始化成功:'); resolve(res); }).catch(err => { reject(err); }); }); } cloudCall(openid) { console.log('等待云函数调用:'); return new Promise((resolve, reject) => { axios.post(this.serverUrl + '/wx/cloud/call', { appid: this.appid, openid }, { headers: { 'auth': this.auth }, timeout: 30 * 1000 }).then(res => { console.log('云函数调用成功:'); resolve(res); }).catch(err => { reject(err); }); }); } } module.exports = WeChatCodeServer;