Skip to content

03 安全模块

zhangwenfeng edited this page Sep 1, 2020 · 1 revision

miot/service/security

安全相关服务

Export: public
Doc_name: 安全模块
Doc_index: 3
Doc_directory: service
Example

import {Service} from 'miot'

Service.security.shareSecureKey(deviceID, shareUid, {})
 .then(secureKey=>{
    ...
 })

Service.security.loadSecureKeys(deviceID).then(secureKeys=>{
   if(secureKeys.length > 0){
      const key = secureKeys[0];
      key.status = 1;
      key.save().then(key=>{...})
   }
})

miot/service/security.ISecureKey

Kind: static interface of miot/service/security


iSecureKey.deviceID : long

设备 ID

Kind: instance property of ISecureKey
Read only: true


iSecureKey.keyID : long

电子钥匙 ID

Kind: instance property of ISecureKey
Read only: true


iSecureKey.shareUserID : string

分享目标的uid

Kind: instance property of ISecureKey
Read only: true


iSecureKey.activeTime : long

生效时间 UTC时间戳,单位为s, active_time

Kind: instance property of ISecureKey


iSecureKey.expireTime

过期时间 UTC时间戳,单位为s, expire_time

Kind: instance property of ISecureKey


iSecureKey.weekdays : [ 'Array' ].<int>

生效日期(星期几,例如周一和周三对应1和3,[1, 3],星期天对应0),仅在status=2时不可为空

Kind: instance property of ISecureKey


iSecureKey.status : int

分享类别,1:暂时,2:周期,3:永久

Kind: instance property of ISecureKey


iSecureKey.isOutOfDate() ⇒

是否过期

Kind: instance method of ISecureKey
Returns: boolean


iSecureKey.save() ⇒ Promise

保存 /share/bluetoothkeyshare

Kind: instance method of ISecureKey


iSecureKey.remove() ⇒ Promise

删除 /share/bluetoothkeyshare

Kind: instance method of ISecureKey


miot/service/security~ISecurity

Kind: inner class of miot/service/security
Export:


iSecurity.loadSecureKeys(deviceID) ⇒ [ 'Promise' ].<Array.<ISecureKey>>

加载设备的安全锁 /share/bluetoothkeyshare

Kind: instance method of ISecurity

Param Type Description
deviceID * 设备ID

iSecurity.shareSecureKey(deviceID, shareUid, [settings]) ⇒ [ 'Promise' ].<ISecureKey>

分享蓝牙锁的钥匙 /share/bluetoothkeyshare 锁固件版本在 2.0.0 及以上, 不支持钥匙的分享

Kind: instance method of ISecurity
Returns: [ 'Promise' ].<ISecureKey> - 分享成功返回锁的信息;reject的时候返回的是object,如果该锁已经分享给被分享人会返回失败,错误码为-101;其他错误情形留意返回的错误信息

Param Type Default Description
deviceID 被分享设备ID
shareUid string 被分享人
[settings] Object {} readonly = true, 则被分享人不可接收锁push,false则被分享人可接收锁push,(family关系用户不受这个字段影响)。status:分享类别,1:暂时,2:周期,3:永久; weekdays 生效日期(星期几,例如周一和周三对应1和3,[1, 3]),仅在status=2时不可为空

iSecurity.getLockBindInfo(deviceID) ⇒ [ 'Promise' ].<json>

获取锁绑定信息, /device/blelockbindinfo 返回数据格式:{"bindtime":1505180216},bindtime是锁的绑定时间

Kind: instance method of ISecurity

Param Type
deviceID string

Clone this wiki locally