03 安全模块 - MiEcosystem/miot-plugin-sdk GitHub Wiki
安全相关服务
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
-
static
-
.ISecureKey
-
.deviceID :
long
-
.keyID :
long
-
.shareUserID :
string
-
.activeTime :
long
- .expireTime
-
.weekdays :
[ 'Array' ].<int>
-
.status :
int
- .isOutOfDate() ⇒
-
.save() ⇒
Promise
-
.remove() ⇒
Promise
-
.deviceID :
-
.ISecureKey
-
inner
-
~ISecurity
-
.loadSecureKeys(deviceID) ⇒
[ 'Promise' ].<Array.<ISecureKey>>
-
.shareSecureKey(deviceID, shareUid, [settings]) ⇒
[ 'Promise' ].<ISecureKey>
-
.getLockBindInfo(deviceID) ⇒
[ 'Promise' ].<json>
-
.loadSecureKeys(deviceID) ⇒
-
~ISecurity
-
static
Kind: static interface of miot/service/security
-
.ISecureKey
-
.deviceID :
long
-
.keyID :
long
-
.shareUserID :
string
-
.activeTime :
long
- .expireTime
-
.weekdays :
[ 'Array' ].<int>
-
.status :
int
- .isOutOfDate() ⇒
-
.save() ⇒
Promise
-
.remove() ⇒
Promise
-
.deviceID :
设备 ID
Kind: instance property of ISecureKey
Read only: true
电子钥匙 ID
Kind: instance property of ISecureKey
Read only: true
分享目标的uid
Kind: instance property of ISecureKey
Read only: true
生效时间 UTC时间戳,单位为s, active_time
Kind: instance property of ISecureKey
过期时间 UTC时间戳,单位为s, expire_time
Kind: instance property of ISecureKey
生效日期(星期几,例如周一和周三对应1和3,[1, 3],星期天对应0),仅在status=2时不可为空
Kind: instance property of ISecureKey
分享类别,1:暂时,2:周期,3:永久
Kind: instance property of ISecureKey
是否过期
Kind: instance method of ISecureKey
Returns: boolean
保存 /share/bluetoothkeyshare
Kind: instance method of ISecureKey
删除 /share/bluetoothkeyshare
Kind: instance method of ISecureKey
Kind: inner class of miot/service/security
Export:
-
~ISecurity
-
.loadSecureKeys(deviceID) ⇒
[ 'Promise' ].<Array.<ISecureKey>>
-
.shareSecureKey(deviceID, shareUid, [settings]) ⇒
[ 'Promise' ].<ISecureKey>
-
.getLockBindInfo(deviceID) ⇒
[ 'Promise' ].<json>
-
.loadSecureKeys(deviceID) ⇒
加载设备的安全锁 /share/bluetoothkeyshare
Kind: instance method of ISecurity
Param | Type | Description |
---|---|---|
deviceID | * |
设备ID |
分享蓝牙锁的钥匙 /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时不可为空 |
获取锁绑定信息, /device/blelockbindinfo 返回数据格式:{"bindtime":1505180216},bindtime是锁的绑定时间
Kind: instance method of ISecurity
Param | Type |
---|---|
deviceID | string |