# hbtosign

> 基于nodejs的弘贝API签名生成工具

Latest version **1.0.4** (published 2019-02-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install hbtosign
pnpm add hbtosign
yarn add hbtosign
bun add hbtosign
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-02-21 |
| First published | 2018-05-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | robo |
| Maintainers | roboxw |

## Links

- npm: https://www.npmjs.com/package/hbtosign
- npm.io page: https://npm.io/package/hbtosign

## Recent versions

- 1.0.4 (latest) — 2019-02-21
- 1.0.3 — 2019-02-15
- 1.0.2 — 2019-02-15
- 1.0.1 — 2018-05-31
- 1.0.0 — 2018-05-30

## README

# HBToSign

基于nodejs的弘贝API签名生成工具

[弘贝签名官方说明](https://www.npmjs.com/package/hbtosign)

安装方法:
```
npm install hbtosign --save
```

使用方法:

例子:[添加域名](https://www.npmjs.com/package/hbtosign)

```javascript
const hbtosign = require("hbtosign");
const querystring = require("querystring");
const moment = require("moment");
const http =require("http");


//基本上调用接口都需要的公共参数
let originParams = {
    format: "JSON",
    version: "2018-05-30",
    signatureMethod: "HMAC-SHA1",
    signatureVersion: "1.0"
}

function AddDomain() {

    //复制一份公共参数
    let params = Object.assign({},originParams); 
    var appKey ="123456", //appKey 获得方法请参照官方文档

    //在新的对象上添加你想调用的该接口必要参数,
    //每个接口都不一样,具体请查阅官方文档
    params.Action = "AddDomain";
    params.DomainName = "honebay.tech";
    params.GroupId = "2223";

    //添加时间戳
    params.Timestamp = moment.utc().format(); //要用格林威治时间;
    params.SignatureNonce = new Date().getTime();
    
    //生成签名
    let signParams = hbtosign(params,appKey);

    //将包含签名属性的对象转换成query格式的字符串
    let queryParams = querystring.stringify(signParams);
    
    //拼接url
    let url = `http://test.honebay.com/v1/test/tosign?` + queryParams;

    //调用接口
    http.get(url, (res) => {
        res.on('data', function (data) {

            //序列化之后,就可以拿到你想要的数据了
            let oData = JSON.parse(data);

        });
    })

} 
```

---
_Source: https://npm.io/package/hbtosign · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
