(Non-official) Wechat mini program (a.k.a. 微信小程序) auth helper for Node.js.
yarn add wxapp-authimport WxappAuth from 'wxapp-auth';
(async function main() {
const wechatAuth = new WxappAuth('<APP_ID>', '<APP_SECRET>');
const userInfo = await wechatAuth.getUserInfo({
code: '<LOGIN_CODE>'
rawData: '<RAW_DATA>',
signature: '<SIGNATURE>',
});
}());new WxappAuth(appId, appSecret);Create a WxappAuth instance.
appId<String>: Wechat app id, requiredappSecret<String>: Wechat app secret, required
wxappAuth.getUserInfo(params);- Params <Object>
code<String>:codefrom wechat mini programwx.login()sessionKey<String>: Session key from getSession(params)rawData<String>:rawDatafrom wechat mini programwx.getUserInfo()signature<String>:signaturefrom wechat mini programwx.getUserInfo()encryptedData<String>:encryptedDatafrom wechat mini programwx.getUserInfo()iv<String>:ivfrom wechat mini programwx.getUserInfo()
- One of
codeorsessionKeyis required - One of
rawDataandsignature, orencryptedDataandivare required
Promise of UserInfo object
wxappAuth.getSession(params);- Params <Object>
code<String>:codefrom wechat mini programwx.login(), required
Promise of object containing sessionKey, openid, and optional unionid
MIT