node-zhongqian
v1.3.0
Published
zhongqian node sdk
Downloads
3
Readme
node-zhongqian - 众签SKD
Install
$ npm install node-zhongqian -S
Basic Usage
const Zhongqian = require('node-zhongqian');
const zhongqian = new Zhongqian({
baseUrl: 'http://xxxx.com',
additionBaseUrl: 'http://xxxx.com', // Third party service api base url
zqid: 'zqid',
privateKey: 'privateKey',
publicKey: 'publicKey'
});
const view = await zhongqian.mobileViewSign({
no: 'contract id',
user_code: 'user code',
sign_type: Zhongqian.ViewSignType.WRITTENCODE,
notify_url: 'url',
return_url: 'url'
});
console.log(view);
Singleton
const Zhongqian = require('node-zhongqian');
Zhongqian.addSingleton('instance', {
baseUrl: 'http://xxxx.com',
additionBaseUrl: 'http://xxxx.com',
zqid: 'zqid',
privateKey: 'privateKey',
publicKey: 'publicKey'
});
Zhongqian.addSingleton('test', {
baseUrl: 'http://xxxx.com',
additionBaseUrl: 'http://xxxx.com',
zqid: 'zqid',
privateKey: 'privateKey',
publicKey: 'publicKey'
});
// Zhongqian.getInstance() function is an alias for Zhongqian.get('instance')
const instance1 = Zhongqian.getInstance();
const instance2 = Zhongqian.get('instance');
assert(instance1 === instance2);
// This will return the singleton named test
const testInstance = Zhongqian.get('test');
Get keys asynchronously
const Zhongqian = require('node-zhongqian');
const params = {
baseUrl: 'http://xxxx.com',
zqid: 'zqid',
// Just pass an asynchronous function
privateKey: async () => {
return new Promise(resolve => setTimeout(() => resolve('private_key'), 1000));
},
publicKey: async () => {
return new Promise(resolve => setTimeout(() => resolve('public_key'), 1000));
}
};
const zhongqian1 = new Zhongqian(params);
Zhongqian.addSingleton('instance', params);
const zhongqian2 = Zhongqian.getInstance();
Questions & Suggestions
Please open an issue here.