7.4.2 • Published 5 months ago
@mixin.dev/mixin-node-sdk v7.4.2
bot-api-nodejs-client
mixin 的 js 版 sdk
新版本特性
- 更友好的类型和代码提示
- 更规范的函数命名
- 更全面的测试覆盖
安装
npm install @mixin.dev/mixin-node-sdk使用 yarn 安装
yarn add @mixin.dev/mixin-node-sdk使用
- 仅使用 Mixin 的 Api
const { MixinApi } = require('@mixin.dev/mixin-node-sdk');
const keystore = {
app_id: '',
session_id: '',
server_public_key: '',
session_private_key: '',
};
const client = MixinApi({ keystore });
// 使用 Promise
client.user.profile().then(console.log);
// 使用 async await
async function getMe() {
const me = await client.user.profile();
console.log(me);
}- 使用 Mixin 的消息功能
const { MixinApi } = require('@mixin.dev/mixin-node-sdk');
const keystore = {
app_id: '',
session_id: '',
server_public_key: '',
session_private_key: '',
};
const config = {
keystore,
blazeOptions: {
parse: true,
syncAck: true,
},
};
const client = MixinApi(config);
client.blaze.loop({
onMessage(msg) {
console.log(msg);
},
});- OAuth 授权
const { MixinApi, getED25519KeyPair, base64RawURLEncode } = require('@mixin.dev/mixin-node-sdk');
const code = ''; // from OAuth url
const app_id = ''; // app_id of your bot
const client_secret = ''; // OAuth Client Secret of your bot
const { seed, publicKey } = getED25519KeyPair(); // Generate random seed and ed25519 key pairs
let client = MixinApi();
const { scope, authorization_id } = await client.oauth.getToken({
client_id: app_id,
code,
ed25519: base64RawURLEncode(publicKey),
client_secret,
});
const keystore = {
app_id,
scope,
authorization_id,
session_private_key: Buffer.from(seed).toString('hex'),
};
client = MixinApi({ keystore });
const user = await client.user.profile();贡献
可接受 PRs.
API
版本所有
Copyright 2024 Mixin.
7.4.0
6 months ago
7.3.1
8 months ago
7.2.2
10 months ago
7.3.0
9 months ago
7.2.1
11 months ago
7.3.5
8 months ago
7.3.4
8 months ago
7.4.2
5 months ago
7.3.3
8 months ago
7.4.1
6 months ago
7.3.2
8 months ago
7.3.8
6 months ago
7.3.7
6 months ago
7.3.6
7 months ago
7.2.0
1 year ago
7.1.0
1 year ago
7.0.9
1 year ago
7.0.10
1 year ago
7.0.8
2 years ago
7.0.7
2 years ago
7.0.6
2 years ago
7.0.4
2 years ago
7.0.3
2 years ago
7.0.5
2 years ago
7.0.2
2 years ago
7.0.1
2 years ago
7.0.0
2 years ago
6.1.1
2 years ago
6.1.0
2 years ago
5.2.3
2 years ago
5.2.2
2 years ago
6.0.0
2 years ago
5.2.1
2 years ago
5.1.2
3 years ago
5.2.0
3 years ago
5.1.0
3 years ago
5.0.0
3 years ago
4.9.0
3 years ago
4.8.0
3 years ago
4.7.2
3 years ago
4.6.0
3 years ago
4.5.0
3 years ago
4.2.0
3 years ago
4.1.2
3 years ago
4.1.0
3 years ago
4.0.0
3 years ago