Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alidns-signature

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alidns-signature

Generate ali DNS cloud API request signature

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

alidns-signature

阿里云DNS开放API签名生成工具

Usage

npm i alidns-signature -S
const http = require('http')
const querystring = require('querystring')
const Signature = require('alidns-signature')
const sign = new Signature({
    accessKeyId: '',
    accessKeySecret: ''
})

// 获取解析记录API的专有参数
let query = sign.getReqParams({
    Action: 'DescribeDomainRecords',
    DomainName: 'example.com'
})

http.get('http://alidns.aliyuncs.com?' + querystring.stringify(query), function (res) {
    let buf = []
    res.on('data', buf.push.bind(buf)).on('end', function () {
        console.log(Buffer.concat(buf).toString())
    })
})

Method

  • getReqParams(params[, httpMethod])

    传入请求query对象和请求方法(默认为GET),返回包含公共参数的新对象

const sign = new Signature({
    accessKeyId: '',
    accessKeySecret: ''
})

// 获取解析记录API的专有参数
let query = sign.getReqParams({
    Action: 'DescribeDomainRecords',
    DomainName: 'example.com'
})
/*
返回对象包含专有参数在内的全部参数,使用 querystring.stringify 序列化成字符串即可使用
{ Format: 'JSON',
  Version: '2015-01-09',
  AccessKeyId: 'LTAIqGVsYW7HAqEf',
  SignatureMethod: 'HMAC-SHA1',
  Timestamp: '2018-05-19T01:52:21.044Z',
  SignatureVersion: '1.0',
  SignatureNonce: 1526694752445,
  Action: 'DescribeDomainRecords',
  DomainName: 'guoyupeng.me',
  Signature: 'wySsR2XAsYhFRke+ZleO7rn9LFk=' }
*/
  • getSignature(params[, httpMethod])

    传入请求query对象和请求方法(默认为GET),返回签名字符串

const sign = new Signature({
    accessKeyId: '',
    accessKeySecret: ''
})

// 接口公共参数
let pubParams = {
    Format: 'JSON',
    Version: '2015-01-09',
    AccessKeyId: '',
    SignatureMethod: 'HMAC-SHA1',
    Timestamp: new Date().toUTCString(),
    SignatureVersion: '1.0',
    SignatureNonce: Date.now()
}

// 获取解析记录API的专有参数
let apiParams = {
    Action: 'DescribeDomainRecords',
    DomainName: 'example.com'
}

// 混合全部参数
let params = Object.assign({}, pubParams, apiParams);

let sign = sign.getSignature(params)
// return 'wySsR2XAsYhFRke+ZleO7rn9LFk='

Keywords

FAQs

Package last updated on 19 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc