Gathering detailed insights and metrics for mixin-node-client
Gathering detailed insights and metrics for mixin-node-client
Gathering detailed insights and metrics for mixin-node-client
Gathering detailed insights and metrics for mixin-node-client
More developer friendly Node.js SDK for Mixin network
npm install mixin-node-client
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (99.21%)
Shell (0.79%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
14 Stars
98 Commits
6 Forks
2 Watchers
18 Branches
2 Contributors
Updated on Mar 26, 2022
Latest Version
0.11.0
Package Id
mixin-node-client@0.11.0
Unpacked Size
328.28 kB
Size
257.28 kB
File Count
27
NPM Version
6.14.6
Node Version
12.18.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Node.js SDK for Mixin Network, heavily inspired by mixin-node, but is much more developer friendly
1yarn add mixin-node-client 2# OR npm install mixin-node-client -S
Steps to use generate config for dapp:
Config file format, remember to replace clientId
and clientSecret
with yours:
1// Generated with awesome https://github.com/wangshijun/mixin-cli 2module.exports = { 3 clientId: '<PUT YOUR DAPP CLIENT_ID HERE>', 4 clientSecret: '<PUT YOUR DAPP CLIENT_SECRET HERE>', 5 assetPin: '310012', 6 sessionId: '621c905b-1739-45e7-b668-b5531dd83646', 7 aesKey: '56GcGs2EFHBPV2Xsb/OiwLdgjGt3q53JcFeLmbUutEk=', 8 privateKey: `-----BEGIN RSA PRIVATE KEY----- 9MIICXAIBAAKBgQCsNaGbDx1UeKrTux01nC6R7/bu2GUELe6Q2mBSPymkZW2fpiaO 10FjkTI1MkEE8Eq1kGm/+6vAP84LMXG/W49UqZTBkKkrQ= 11-----END RSA PRIVATE KEY-----`, 12};
HttpClient
provides wrapper for all API supported by mixin network and mixin messenger, such as pin/user/asset/snapshot:
1const { HttpClient } = require('mixin-node-client'); 2const config = require('./config'); 3 4const client = new HttpClient(config); 5 6const recipientId = 'ca630936-5af6-427e-ac4a-864a4c64f372'; // UserId 7const senderId = '7701e7bf-2a86-4655-982e-023564fa8945'; // UserID 8const assetId = '965e5c6e-434c-3fa9-b780-c50f43cd955c'; // CNB 9 10(async () => { 11 const assets = await client.getAssets(); 12 const verifyPin = await client.verifyPin(config.assetPin); 13 const user = await client.getUser(senderId); 14 console.log({ assets, verifyPin, user }); 15})();
Full API list supported by HttpClient
:
Working example for HttpClient
can be found HERE
Because we can send messages to a conversation, HttpClient
provide neat methods to send all kinds of message to Mixin Messenger:
1console.log(client.getMessageSenders()); 2// [ 'sendText', 3// 'sendImage', 4// 'sendVideo', 5// 'sendData', 6// 'sendSticker', 7// 'sendContact', 8// 'sendButton', 9// 'sendButtons', 10// 'sendApp' ] 11const text = await client.sendText({ 12 conversationId: conversation.conversation_id, 13 data: 'Hello from node.js new client sdk', 14}); 15const button = await client.sendButton({ 16 conversationId: conversation.conversation_id, 17 data: { label: 'Open Mixin', color: '#FF0000', action: 'https://mixin.one' }, 18});
For syntax of sending messages, see working example HERE.
SocketClient
provide basic wrapper for Mixin Messenger WebSocket Messages, you can use it to listen and react to socket messages.
1const { SocketClient } = require('mixin-node-client'); 2const config = require('./config'); 3 4const client = new SocketClient(config); 5 6socket.on( 7 'message', 8 socket.getMessageHandler(message => { 9 console.log('Message Received', message); 10 if (message.data && message.data.category === 'PLAIN_TEXT' && message.data.data.toLowerCase() === 'hi') { 11 // We support `sendText`, `sendButton`, `sendImage` here 12 return socket.sendText('Hi there!', message); 13 } 14 15 return Promise.resolve(message); 16 }) 17);
Working example for SocketClient
can be found HERE
Same set of message sender utils are also supported by SocketClient
(Note: parameters are different for message sender utils of HttpClient
and SocketClient
, because we have the conversationId from the onMessage
callback):
1socket.sendText('Hi there!', message); 2socket.sendButton({ label: 'Open Mixin', color: '#FF0000', action: 'https://mixin.one' }, message);
If you are curious what happened during each API call, try run example code with following command:
1DEBUG=mixin-node-client:* node examples/http.js 2DEBUG=mixin-node-client:* node examples/socket.js 3DEBUG=mixin-node-client:* node examples/message.js
The mixin dapp included in the examples folder can be found with the following qrcode:
Name |
---|
wangshijun |
MIT © wangshijun
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
73 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More