1.3.0 • Published 5 years ago

node-zhongqian v1.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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.

License

MIT

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago