npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dun-sms

v0.0.5

Published

网易易盾短信验证码 https://dun.163.com/

Readme

网易易盾短信验证码 for nodejs

功能概述

  • 国内验证码短信 - 发送国内验证码和校验验证码
  • 国内通知类短信 - 发送国内通知

使用前必读

版本要求

nodejs >= 8.3.0

安装

npm i dun-sms

# 如已安装旧版, 重新安装最新版
npm i dun-sms@latest

实例化

const {SMS} = require("dun-sms")
const config = {
  secretId: '产品秘钥id',
  secretKey: '产品私钥'
};
// 一般模式
const api = new SMS(config);

// 调试模式(传入第二个参数为true, 可在控制台输出数据)
const api = new SMS(config, true);

config说明:

  • secretId - 产品秘钥id(必填)
  • secretKey - 产品私钥(必填)

通用响应字段

所有接口响应值采用 json 格式, 如无特殊说明,每次请求的返回值中,都包含下面字段:

| 参数名称 | 类型 | 描述 | | -------- | ------ | ------------------------------------------------------------ | | code | Number | 接口调用状态,200:正常,其他值:调用出错,返回码见 响应返回码 | | msg | String | String 结果说明,如果接口调用出错,那么返回错误描述,成功返回 ok | | data | Object | 接口返回结果,各个接口自定义 |

功能

1.发送短信验证码:

/**
* 发送短信验证码
* @param mobile 手机号 (必填)
* @param code 短信内容 (选填)
* @param templateId 模板id (必填)
* @param businessId 国内验证码短信 业务id (必填)
* @return
*/
sendCode(mobile, code, templateId, businessId){}

说明:

  • code - 短信内容(选填) 验证码数字个数,支持范围4-10 .如果code为空或者不传,则默认生成6位验证码
  • 验证码有效期为300秒

响应结果

响应字段如下,响应通用字段已省略,详细见 ###通用响应字段

data 数据结构

| 参数名称 | 类型 | 描述 | | --------- | ------ | ------------------------------------------------------------ | | result | Number | 接口调用状态,200:正常,其他值:调用出错,返回码见下方响应结果码 | | requestId | String | 本次请求的唯一标识符,若使用易盾提供的验证码校验功能,该字段将作为验证传参之一 |

2.校验短信验证码:

/**
     * 验证码校验
     * @param {*} requestId 短信发送接口返回的requestId字段
     * @param {*} code 用户填写的验证码
     * @returns 
     */
verify(requestId, code, businessId){}

请求参数:

| 参数名称 | 类 型 | 是否必选 | 最大长度 | 描述 | | --------- | ------ | -------- | -------- | ------------------------------- | | requestId | String | Y | 32 | 短信发送接口返回的requestId字段 | | code | String | Y | 10 | 用户填写的验证码 |

响应结果

响应字段如下,响应通用字段已省略,详细见 ###通用响应字段

data 数据结构

| 参数名称 | 类型 | 描述 | | ---------- | ------- | --------------------------------------------------- | | match | Boolean | 校验结果 | | reasonType | Number | 原因(1-一致, 2-不一致, 3-requestId过期或不存在) |

3.发送自定义短信:

/**
     * 发送自定义短信
     * @param mobile 手机号
     * @param json 短信内容
     * @param templateId 模板id
     * @param businessId 国内通知类短信 业务id
     * @return
     */
      sendData(mobile, json, templateId, businessId){}

示例:


// 模板为:预订通知:用户${name}已成功预定${room}房间,预定时间自${start}至${end}止。
 let json = {
    "name":"杜先生",
    "room":"VIP888房间",
    "start":"2022-01-07 10:00",
    "end":"2022-01-07 16:00"
}
 await api.sendData(13800138000,json,"模板id","国内通知类短信 业务id")

响应结果

响应字段如下,响应通用字段已省略,详细见 ###通用响应字段

data 数据结构

| 参数名称 | 类型 | 描述 | | --------- | ------ | ------------------------------------------------------------ | | result | Number | 接口调用状态,200:正常,其他值:调用出错,返回码见下方响应结果码 | | requestId | String | 本次请求的唯一标识符,若使用易盾提供的验证码校验功能,该字段将作为验证传参之一 |

其他说明

详细信息参照: https://support.dun.163.com/documents/2018101001?docId=210168759616458752