
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
微信小程序公众平台后台功能非官方 SDK
帮助构建小程序自动化系统,小程序管理后台
$ npm install --save mina-admin
const {Admin} = require('mina-admin');
const admin = new Admin({
account: "",
password: ""
});
await admin.init();
await admin.login();
const users = await admin.command("mina_expr_users")({
type: "list"
});
STORAGE_FILE: 定义运行过程中用户数据(cookie...)存储的路径, 默认为 lib/.storage
CRYPTO_KEY: 用户数据加密秘钥
const admin = new Admin({
account: "", // 微信小程序后台登录账号
password: "" // 微信小程序后台登录密码
})
使用前必须先调用初始化方法
admin.init()
调用后台功能前必须先登录,第一次登录或者登录会话过期,会在控制台中打印二维码,需要管理员通过微信进行扫码登录。
通过监听 qrcode 事件,在回调中获取二维码,开发者可以通过自定义方式发送二维码给管理员。
通过监听 login-expired 事件,处理登录过期,并添加重新登录逻辑。
admin.on('qrcode', (imageBuffer) => {
})
await admin.login();
admin.on('login-expired', () => {
admin.login()
})
除了使用默认小程序后台指令外,开发者还可以编写自定义指令并注册
admin.registerCommand(Command)
执行指令有两种不同的方式
admin.exec('cmd_name', args)
admin.command('cmd_name')(args)
admin.getUser()
提供小程序版本管理功能(获取所有版本列表,版本设为体验版,版本提审,撤回提审,版本发布)
// 获取当前的小程序版本(线上版本,审核版本,开发版本)
const codes = await admin.exec("mina_code", {
type: 'list'
});
console.log(codes.dev) // 开发版本 [Code, Code]
console.log(codes.exper) // 体验版本 Code
console.log(codes.online) // 线上版本 Code
// 版本设为体验版
const codes = await admin.exec("mina_code", {
type: 'expr',
code: Code
});
// 版本提审
const codes = await admin.exec("mina_code", {
type: 'review',
code: Code
});
// 撤回提审
const codes = await admin.exec("mina_code", {
type: 'cancel_review'
});
// 版本发布到线上
const codes = await admin.exec("mina_code", {
type: 'publish',
code: Code
});
提供小程序体验成员管理(查询,添加,删除)
// 获取所有有体验版权限的成员
const users = await admin.exec("mina_expr_users", {
type: 'list'
});
console.log(users) // [User, User]
// 添加指定用户为体验版成员
const users = await admin.exec("mina_expr_users", {
type: 'add',
users: [User, User]
});
// 删除指定体验版成员
const users = await admin.exec("mina_expr_users", {
type: 'remove',
users: [User, User]
});
生成任意小程序的小程序码
// 生成小程序码
const base64ImageStr = await admin.exec("mina_qrcode", {
type: 'gen',
appId: '抽奖助手',
appPath: 'pages/index'
});
console.log(base64ImageStr) // Base64 encode image string
// 获取 appId
const appId = await admin.exec("mina_qrcode", {
type: 'appid',
appName: '抽奖助手'
});
小程序工具指令,支持复制小程序路径
// 开启客户端复制小程序路径功能
// 该微信用户可打开小程序右上角菜单,点击“复制页面路径”并粘贴至左侧“小程序页面路径”中
const isSuccess = await admin.exec("mina_tools", {
type: 'copy-path',
appId: '抽奖助手',
userName: 'yanhaibiao1991'
});
// 获取 appId
const appId = await admin.exec("mina_tools", {
type: 'appid',
appName: '抽奖助手'
});
生成任意小程序的小程序码
// 生成小程序码
const base64ImageStr = await admin.exec("mina_qrcode", {
type: 'gen',
appId: '抽奖助手',
appPath: 'pages/index'
});
console.log(base64ImageStr) // Base64 encode image string
// 获取 appId
const appId = await admin.exec("mina_qrcode", {
type: 'appid',
appName: '抽奖助手'
});
小程序获取公众号文章渠道来源数据
const resp = await admin.exec("mina_visit_official_source", {
page: 1,
pageCount: 10
});
开发者通过继承 Command 来编写自定义指令, 具体例子可以查看 lib/commands 目录中的内置指令
内置指令类名和所在文件名必须符合 AxxBxxCommand 的格式, 指令名解析为 axx_bxx
const {Command} = require("mina-admin");
class CustomCommand extends Command {
async exec() {
// 指令功能入口
}
clean() {
// 指令执行完成的清理函数
}
}
封装了 node-fetch, 会设置额外的 url 参数和 cookie 绕过微信接口身份认证
let resp = await command.fetch(
`https://mp.weixin.qq.com/wxamp/cgi/route?`
);
封装了 jsdom, 简化处理 html
const dom = command.don("html text");
const document = dom.window.document;
document.querySelector("a")
MINA_CODE_IN_DEV: 开发版本
MINA_CODE_IN_REVIEW: 审核中
MINA_CODE_REVIEW_PASS: 已过审待发布
BSD-3-Clause © alexayan
FAQs
mina admin
The npm package mina-admin receives a total of 3 weekly downloads. As such, mina-admin popularity was classified as not popular.
We found that mina-admin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.