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

@ray-js/wechat-ms-basic

v0.0.8

Published

> @ray-js/wechat-ms-basic 该 SDK 提供了门锁小程序的基础能力,包括远程开锁、获取实时视频拉流地址、获取视频首桢图、判断设备类型等

Readme

@ray-js/wechat-ms-basic 该 SDK 提供了门锁小程序的基础能力,包括远程开锁、获取实时视频拉流地址、获取视频首桢图、判断设备类型等

安装

yarn add @ray-js/wechat-ms-basic
// or
npm install @ray-js/wechat-ms-basic

查询用户详细信息(分享成员不可用)

getUser

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :--------------- | :------------------------------- | -------- | | device_id | string | 设备 ID | true | | user_id | string or number | 用户 ID,默认是 0 ,查询当前用户 | false |

返回参数

| 参数名 | 类型 | 描述 | | :----------- | :------------------------ | :------------------------------------------------- | | avatar_url | string | 头像 URL | | lock_user_id | number | 锁用户 id | | nick_name | string | 昵称 | | user_contact | string | 联系方式 | | user_id | string | 用户 id | | user_type | 0 or 10 or 20 or 30 or 50 | 0-未知人员类型, 10-管理员, 20-普通家人,30-标记成员 |

请求示例

import MsBasicApi from '@ray-js/wechat-ms-basic';

MsBasicApi.getUser(device_id)
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

返回示例

{
  user_type: 50,
  avatar_url: 'https://images.tuyacn.com/xxxxxxx.png',
  user_id: '5958862',
  nick_name: '多肉',
  user_contact: '',
  lock_user_id: 1
}

获取远程开锁密钥

getRemoteUnlockTicket

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :---------- | :----- | :----------- | | ticket_id | string | 临时秘钥 ID | | ticket_key | string | 临时秘钥 Key | | expire_time | number | 剩余有效时间 |

远程开锁

getRemoteUnlock

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :-------------------------------------------- | -------- | | device_id | string | 设备 ID | true | | ticket_id | string | 授权的密钥 ID(getRemoteUnlockTicket 中获取) | true |

返回参数

boolean: 是否开锁成功

拒绝远程开锁请求

rejectRemoteUnlock

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

boolean: 是否成功

获取设备下的最新DP数据

getLastDpCache

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

各个dp数据json

获取硬件设备型号信息

getHardwareType

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :------- | :----- | :------------------------------- | | code | string | code === 'videolock' 表示高端锁; | | hardware | string | 硬件类型 |

查询最近一次 DP212 上报的数据

getLatestDp212

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :------- | :----- | :----------------- | | file_key | string | 加密密钥 | | file_url | string | 文件地址(全路径) | | angle | number | 旋转角度 |

获取加密的首桢图地址

getDecryptUrl

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :------------ | :----- | :---------------------------------------------------------------------------------- | -------- | | device_id | string | 设备 ID | true | | encrypted_url | string | 文件url,需要做base64编码处理(对从getLatestDp212中获取的file_url做base64编码处理) | true | | secret_key | string | 文件key(从getLatestDp212中获取的file_key) | true |

返回参数

| 参数名 | 类型 | 描述 | | :----- | :----- | :------------------------- | | url | string | 图片地址,需要做base64解码 |

使用示例

import MsBasicApi from '@ray-js/wechat-ms-basic';

const result = await MsBasicApi.getLatestDp212(device_id);
const { file_key, file_url, angle } = result;
const encodeUrl = await MsBasicApi.getDecryptUrl({
  device_id,
  encrypted_url: MsBasicApi.base64encode(file_url),
  secret_key: file_key,
});
const imgUrl = MsBasicApi.base64decode(encodeUrl);

获取实时视频拉流地址

getLockMediaStream

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :----- | :----- | :------- | | url | string | 拉流地址 |

获取旋转角度

getRotateAngle

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :----- | :----- | :------- | | angle | number | 旋转角度 |

获取 Skill 技能(视频流的宽高等)

getDevSkill

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

string: 需要将字符串传为json

###返回示例

'{"cloudGW":1,"cloudP2P":1,"audios":[{"channels":1,"dataBit":16,"codecType":106,"sampleRate":8000}],"videos":[{"streamType":2,"profileId":"","width":1280,"codecType":2,"sampleRate":90000,"height":720}],"p2p":4}';

h264设备判断: videos[0].codecType === 2 && videos[0].streamType === 2

获取rtc配置,包含 Skill 技能

getRtcConfig

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------ | -------- | | device_id | string | 设备 ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :----- | :----- | :----------------------- | | skill | string | skill技能,同getDevSkill |

获取clientId

getAppClientId

请求参数

无

返回参数

string: clientId

获取ticket

getTicket

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :----- | :----- | :----- | -------- | | uid | string | 用户ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :---------- | :----- | :------- | | ticket | string | ticket | | expire_time | number | 失效时间 |

获取最近一次的远程开门或告警封面图

getMediaUrl

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :------------------------- | -------- | | device_id | string | 设备ID | true | | file_type | number | 文件类型 1:远程开门 2:告警 | true |

返回参数

| 参数名 | 类型 | 描述 | | :-------- | :----- | :------------- | | file_url | string | 封面图完整路径 | | file_key | string | 文件解密密钥 | | bucket | string | 封面图完整路径 | | file_path | string | 文件的相对路径 |

获取 dp 数据解密后的url

getDecryptUrlByDpData

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :----------- | -------- | | device_id | string | 设备ID | true | | dp_data | sting | 加密的dp数据 | true |

返回参数

string: 需要base64解码

获取NG后台配置信息

getProductConfig

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :-------------------------------------------- | -------- | | device_id | string | 设备ID | true | | props | sting | 属性名(多个逗号分隔,如果为空,则返回所有设置) | true |

返回参数

json

检验设备是否具有如下高级能力

getCapabilityTag

请求参数

| 参数名 | 类型 | 描述 | 是否必传 | | :-------- | :----- | :----- | -------- | | device_id | string | 设备ID | true |

返回参数

| 参数名 | 类型 | 描述 | | :-------- | :------ | :------------------------- | | isHas100w | boolean | 是否具备100w视频标高级能力 | | isHas200w | boolean | 是否具备200w视频标高级能力 |