@ray-js/lock-sdk 1.0.0-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.js +18 -0
- package/lib/api/linkage.d.ts +161 -0
- package/lib/api/linkage.js +74 -0
- package/lib/api/lock.d.ts +195 -0
- package/lib/api/lock.js +129 -0
- package/lib/api/log.d.ts +166 -0
- package/lib/api/log.js +44 -0
- package/lib/api/setting.d.ts +14 -0
- package/lib/api/setting.js +36 -0
- package/lib/api/temp.d.ts +211 -0
- package/lib/api/temp.js +130 -0
- package/lib/api/user.d.ts +154 -0
- package/lib/api/user.js +59 -0
- package/lib/api/video.d.ts +9 -0
- package/lib/api/video.js +17 -0
- package/lib/config/dp-code/index.d.ts +175 -0
- package/lib/config/dp-code/index.js +224 -0
- package/lib/config/dp-map/common.d.ts +102 -0
- package/lib/config/dp-map/common.js +120 -0
- package/lib/config/dp-map/normal.d.ts +6 -0
- package/lib/config/dp-map/normal.js +51 -0
- package/lib/config/dp-map/open.d.ts +21 -0
- package/lib/config/dp-map/open.js +62 -0
- package/lib/config/dp-map/unlock-method-big.d.ts +559 -0
- package/lib/config/dp-map/unlock-method-big.js +237 -0
- package/lib/config/dp-map/unlock-method.d.ts +551 -0
- package/lib/config/dp-map/unlock-method.js +231 -0
- package/lib/config/index.d.ts +46 -0
- package/lib/config/index.js +56 -0
- package/lib/constant.d.ts +101 -0
- package/lib/constant.js +136 -0
- package/lib/dp-interface.d.ts +7 -0
- package/lib/dp-interface.js +1 -0
- package/lib/event.d.ts +8 -0
- package/lib/event.js +9 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.js +92 -0
- package/lib/interface.d.ts +807 -0
- package/lib/interface.js +1 -0
- package/lib/linkage.d.ts +26 -0
- package/lib/linkage.js +175 -0
- package/lib/log.d.ts +91 -0
- package/lib/log.js +314 -0
- package/lib/media.d.ts +43 -0
- package/lib/media.js +80 -0
- package/lib/open.d.ts +48 -0
- package/lib/open.js +247 -0
- package/lib/other.d.ts +36 -0
- package/lib/other.js +178 -0
- package/lib/parse/index.d.ts +6 -0
- package/lib/parse/index.js +22 -0
- package/lib/signal.d.ts +26 -0
- package/lib/signal.js +38 -0
- package/lib/sleep.d.ts +61 -0
- package/lib/sleep.js +121 -0
- package/lib/state.d.ts +54 -0
- package/lib/state.js +429 -0
- package/lib/sync/remote-serect-key.d.ts +5 -0
- package/lib/sync/remote-serect-key.js +60 -0
- package/lib/sync/t0.d.ts +5 -0
- package/lib/sync/t0.js +33 -0
- package/lib/sync/temp.d.ts +7 -0
- package/lib/sync/temp.js +88 -0
- package/lib/sync/unlock-mothod.d.ts +5 -0
- package/lib/sync/unlock-mothod.js +54 -0
- package/lib/temporary.d.ts +226 -0
- package/lib/temporary.js +637 -0
- package/lib/unlock-method.d.ts +269 -0
- package/lib/unlock-method.js +723 -0
- package/lib/user.d.ts +108 -0
- package/lib/user.js +361 -0
- package/lib/utils/base64-to-hex.d.ts +1 -0
- package/lib/utils/base64-to-hex.js +12 -0
- package/lib/utils/byte.d.ts +19 -0
- package/lib/utils/byte.js +74 -0
- package/lib/utils/constant.d.ts +11 -0
- package/lib/utils/constant.js +17 -0
- package/lib/utils/device.d.ts +207 -0
- package/lib/utils/device.js +353 -0
- package/lib/utils/errors.d.ts +2 -0
- package/lib/utils/errors.js +125 -0
- package/lib/utils/event.d.ts +23 -0
- package/lib/utils/event.js +144 -0
- package/lib/utils/hex-to-base64.d.ts +1 -0
- package/lib/utils/hex-to-base64.js +8 -0
- package/lib/utils/hex-to-bytes.d.ts +6 -0
- package/lib/utils/hex-to-bytes.js +16 -0
- package/lib/utils/index.d.ts +169 -0
- package/lib/utils/index.js +419 -0
- package/lib/utils/log.d.ts +5 -0
- package/lib/utils/log.js +78 -0
- package/lib/utils/publishDps.d.ts +11 -0
- package/lib/utils/publishDps.js +91 -0
- package/package.json +37 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { checkRemoteKey } from "../api/lock";
|
|
2
|
+
import config from "../config";
|
|
3
|
+
import dpCodes from "../config/dp-code";
|
|
4
|
+
import { getCurrentUser, getDpValue } from "../state";
|
|
5
|
+
import { isUseNearChannel } from "../utils";
|
|
6
|
+
import { stringToBytes } from "../utils/byte";
|
|
7
|
+
import { decrypt } from "../utils/device";
|
|
8
|
+
import { publishDpsOnly } from "../utils/publishDps";
|
|
9
|
+
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
10
|
+
import { reportSetKey as reportSetKeyMap, setKey as setKeyMap } from "../config/dp-map/open";
|
|
11
|
+
import { ProductCommunicationType } from "../constant";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 同步密钥
|
|
15
|
+
*/
|
|
16
|
+
const syncRemoteSerectKey = async () => {
|
|
17
|
+
const useNear = isUseNearChannel();
|
|
18
|
+
if (useNear) {
|
|
19
|
+
try {
|
|
20
|
+
const isSupportBle = config.communication.includes(ProductCommunicationType.BLUETOOTH);
|
|
21
|
+
// 双模下
|
|
22
|
+
if (config.communication.length > 1 && isSupportBle) {
|
|
23
|
+
// 如果当前的远程解锁密钥设置 为空、或失败、或主动请求获取,则进行同步
|
|
24
|
+
const keyValue = getDpValue(dpCodes.remoteNoPdSetkey);
|
|
25
|
+
if (keyValue) {
|
|
26
|
+
const keyData = dpUtils.parse(getDpValue(dpCodes.remoteNoPdSetkey), reportSetKeyMap);
|
|
27
|
+
// 已成功同步,则不进行同步
|
|
28
|
+
if (keyData.status === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const {
|
|
33
|
+
lockUserId,
|
|
34
|
+
userId
|
|
35
|
+
} = await getCurrentUser();
|
|
36
|
+
// 如果为开启,并在蓝牙下的,则同步密钥
|
|
37
|
+
const {
|
|
38
|
+
password,
|
|
39
|
+
invalidTime,
|
|
40
|
+
effectiveTime
|
|
41
|
+
} = await checkRemoteKey(config.devInfo.devId);
|
|
42
|
+
const pw = await decrypt(config.devInfo.devId, password);
|
|
43
|
+
// 如为开启时,同步密钥
|
|
44
|
+
publishDpsOnly({
|
|
45
|
+
[dpCodes.remoteNoPdSetkey]: dpUtils.format({
|
|
46
|
+
valid: true,
|
|
47
|
+
memberId: lockUserId !== 0 ? lockUserId : userId,
|
|
48
|
+
startTime: effectiveTime,
|
|
49
|
+
endTime: invalidTime,
|
|
50
|
+
validNum: 100,
|
|
51
|
+
key: stringToBytes(pw)
|
|
52
|
+
}, setKeyMap)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.warn(e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export default syncRemoteSerectKey;
|
package/lib/sync/t0.d.ts
ADDED
package/lib/sync/t0.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 同步 T0 时间
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getActiveTime } from "../api";
|
|
6
|
+
import config from "../config";
|
|
7
|
+
import dpCodes from "../config/dp-code";
|
|
8
|
+
import { ProductCommunicationType } from "../constant";
|
|
9
|
+
import { isUseNearChannel } from "../utils";
|
|
10
|
+
import { publishDpsOnly } from "../utils/publishDps";
|
|
11
|
+
let hasSysncT0 = false;
|
|
12
|
+
const isNeedSync = () => {
|
|
13
|
+
const near = isUseNearChannel();
|
|
14
|
+
return near || config.devInfo.isOnline && config.communication.includes(ProductCommunicationType.THREAD);
|
|
15
|
+
};
|
|
16
|
+
const syncT0 = async () => {
|
|
17
|
+
// 如果已经同步过 T0 时间,则不再重复同步
|
|
18
|
+
if (hasSysncT0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// dp 存在,并且设备满足近场通道要求或为 matter 设备时
|
|
22
|
+
if (config.dpSchema[dpCodes.passwordOfflineTime]) {
|
|
23
|
+
if (isNeedSync()) {
|
|
24
|
+
hasSysncT0 = true;
|
|
25
|
+
const time = await getActiveTime(config.devInfo.devId);
|
|
26
|
+
// 下发 T0 时间
|
|
27
|
+
publishDpsOnly({
|
|
28
|
+
[dpCodes.passwordOfflineTime]: time.toString()
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default syncT0;
|
package/lib/sync/temp.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
import { getSyncTempPasswords } from "../api/temp";
|
|
5
|
+
import config from "../config";
|
|
6
|
+
import dpCodes from "../config/dp-code";
|
|
7
|
+
import { addTempPwd as addTempPwdDpMap, removeTempPwd as removeTempPwdDpMap } from "../config/dp-map/unlock-method";
|
|
8
|
+
import { addTempPwd as addTempPwdBigDpMap, removeTempPwd as removeTempPwdBigDpMap } from "../config/dp-map/unlock-method-big";
|
|
9
|
+
import { isUseNearChannel, parseWeek } from "../utils";
|
|
10
|
+
import { decrypt } from "../utils/device";
|
|
11
|
+
import { publishDps } from "../utils/publishDps";
|
|
12
|
+
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
13
|
+
|
|
14
|
+
// 标记是否有同步过,如果同步过,则 SDK 不在主动同步
|
|
15
|
+
let syncTempFirst = true;
|
|
16
|
+
/**
|
|
17
|
+
* 同步临时密码
|
|
18
|
+
* 仅在近场通讯时使用
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export const syncTemp = async () => {
|
|
22
|
+
try {
|
|
23
|
+
syncTempFirst = false;
|
|
24
|
+
const {
|
|
25
|
+
pwdList
|
|
26
|
+
} = await getSyncTempPasswords({
|
|
27
|
+
devId: config.devInfo.devId,
|
|
28
|
+
isUpt: false
|
|
29
|
+
});
|
|
30
|
+
const delDpCode = config.supportBigData ? dpCodes.tempPwdDelW : dpCodes.tempPwdDel;
|
|
31
|
+
const delDpMap = config.supportBigData ? removeTempPwdBigDpMap : removeTempPwdDpMap;
|
|
32
|
+
const addDpCode = config.supportBigData ? dpCodes.tempPwdCreateW : dpCodes.tempPwdCreate;
|
|
33
|
+
const addDpMap = config.supportBigData ? addTempPwdBigDpMap : addTempPwdDpMap;
|
|
34
|
+
pwdList === null || pwdList === void 0 || pwdList.forEach(async syncItem => {
|
|
35
|
+
try {
|
|
36
|
+
// 删除
|
|
37
|
+
if ((syncItem === null || syncItem === void 0 ? void 0 : syncItem.opt) === 4) {
|
|
38
|
+
publishDps({
|
|
39
|
+
[delDpCode]: dpUtils.format({
|
|
40
|
+
unlockId: syncItem === null || syncItem === void 0 ? void 0 : syncItem.sn
|
|
41
|
+
}, delDpMap)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// 添加
|
|
45
|
+
if ((syncItem === null || syncItem === void 0 ? void 0 : syncItem.opt) === 5) {
|
|
46
|
+
const {
|
|
47
|
+
allDay,
|
|
48
|
+
invalidTime,
|
|
49
|
+
effectiveTime,
|
|
50
|
+
workingDay
|
|
51
|
+
} = syncItem.scheduleList[0];
|
|
52
|
+
const pwd = await decrypt(config.devInfo.devId, syncItem.password);
|
|
53
|
+
const pswData = pwd.split("").map(item => Number(item));
|
|
54
|
+
publishDps({
|
|
55
|
+
[addDpCode]: dpUtils.format({
|
|
56
|
+
cloudNo: syncItem.tyNum,
|
|
57
|
+
valid: true,
|
|
58
|
+
validConfig: {
|
|
59
|
+
startTime: syncItem.effectiveTime,
|
|
60
|
+
endTime: syncItem.invalidTime,
|
|
61
|
+
loop: allDay ? 0x00 : 0x01,
|
|
62
|
+
loopConfig: 0,
|
|
63
|
+
weeks: parseWeek(workingDay),
|
|
64
|
+
days: 0,
|
|
65
|
+
startHour: Math.floor(effectiveTime / 60),
|
|
66
|
+
startMinute: effectiveTime % 60,
|
|
67
|
+
endHour: Math.floor(invalidTime / 60),
|
|
68
|
+
endMinute: invalidTime % 60
|
|
69
|
+
},
|
|
70
|
+
validNum: 0,
|
|
71
|
+
pwdLength: pswData.length,
|
|
72
|
+
pwd: pswData
|
|
73
|
+
}, addDpMap)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.warn("sync temp password error", e);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.log(e, "sync temp password error");
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export const autoSyncTemp = () => {
|
|
85
|
+
if (isUseNearChannel()) {
|
|
86
|
+
syncTempFirst && syncTemp();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { fetchSyncUnlockMethodInfo } from "../api/lock";
|
|
2
|
+
import config from "../config";
|
|
3
|
+
import dpCodes from "../config/dp-code";
|
|
4
|
+
import { getCurrentUser } from "../state";
|
|
5
|
+
import { publishDps } from "../utils/publishDps";
|
|
6
|
+
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
7
|
+
import { reportSync as reportSyncMap } from "../config/dp-map/unlock-method";
|
|
8
|
+
import { reportSync as reportSyncBigMap } from "../config/dp-map/unlock-method-big";
|
|
9
|
+
|
|
10
|
+
// 标记是否有同步过,如果同步过,则 SDK 不在主动同步
|
|
11
|
+
let syncUnlockMethodFirst = true;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 同步开锁方式
|
|
15
|
+
*/
|
|
16
|
+
export const syncUnlockMethod = async () => {
|
|
17
|
+
syncUnlockMethodFirst = false;
|
|
18
|
+
const {
|
|
19
|
+
allOpenDps = ""
|
|
20
|
+
} = await getCurrentUser();
|
|
21
|
+
const {
|
|
22
|
+
ins = "",
|
|
23
|
+
distributed = false
|
|
24
|
+
} = await fetchSyncUnlockMethodInfo({
|
|
25
|
+
devId: config.devInfo.devId,
|
|
26
|
+
dpIds: allOpenDps.split(",")
|
|
27
|
+
});
|
|
28
|
+
if (ins && distributed) {
|
|
29
|
+
const dpCode = config.supportBigData ? dpCodes.synchMethodW : dpCodes.synchMethod;
|
|
30
|
+
// 下发同步dp
|
|
31
|
+
await publishDps({
|
|
32
|
+
[dpCode]: ins
|
|
33
|
+
}, {
|
|
34
|
+
checkReport: dpData => {
|
|
35
|
+
if (typeof dpData[dpCode] !== "undefined") {
|
|
36
|
+
const result = dpUtils.parse(dpData[dpCode], config.supportBigData ? reportSyncBigMap : reportSyncMap);
|
|
37
|
+
if (result.stage === 1) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export const autoSyncUnlockMethod = async () => {
|
|
47
|
+
try {
|
|
48
|
+
if (syncUnlockMethodFirst) {
|
|
49
|
+
await syncUnlockMethod();
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// 不处理
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { EffectiveConfig, TemporaryPasswordType, TempPasswordResult } from "./interface";
|
|
2
|
+
interface CreateCustomParams {
|
|
3
|
+
/**
|
|
4
|
+
* 密码内容,必须是数字
|
|
5
|
+
*/
|
|
6
|
+
password: string;
|
|
7
|
+
/**
|
|
8
|
+
* 密码名称,长度不能超过20个字符
|
|
9
|
+
*/
|
|
10
|
+
name?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 密码时效配置
|
|
13
|
+
*/
|
|
14
|
+
effective: EffectiveConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 创建自定义临时密码
|
|
18
|
+
* @param {CreateCustomParams} params - 创建临时密码的参数
|
|
19
|
+
* @returns {Promise<boolean>} - 返回创建结果
|
|
20
|
+
* @throws {ErrorData} - 如果创建失败,将抛出错误
|
|
21
|
+
*/
|
|
22
|
+
export declare const createTempCustom: (params: CreateCustomParams) => Promise<TempPasswordResult>;
|
|
23
|
+
interface RemoveCustomProps {
|
|
24
|
+
unlockBindingId: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 删除自定义密码
|
|
28
|
+
* @param {RemoveCustomProps} params
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare const removeTempCustom: (params: RemoveCustomProps) => Promise<unknown>;
|
|
32
|
+
interface UpdateTempPasswordParams {
|
|
33
|
+
/**
|
|
34
|
+
* 密码 id
|
|
35
|
+
*/
|
|
36
|
+
unlockBindingId: string;
|
|
37
|
+
/**
|
|
38
|
+
* 密码名称,长度不能超过20个字符
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* 密码时效配置
|
|
43
|
+
*/
|
|
44
|
+
effective: EffectiveConfig;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 更新自定义临时密码
|
|
48
|
+
* 注意,当前只支持更新名称和时效配置,且只支持走云端更新。
|
|
49
|
+
* @param {UpdateTempPasswordParams} params 更新临时密码的参数
|
|
50
|
+
* @returns {Promise<void>} - 返回更新结果
|
|
51
|
+
* @throws {ErrorData} - 如果更新失败,将抛出错误
|
|
52
|
+
*/
|
|
53
|
+
export declare const updateTempCustom: (params: UpdateTempPasswordParams) => Promise<boolean | undefined>;
|
|
54
|
+
interface CreateLimitParams {
|
|
55
|
+
/**
|
|
56
|
+
* 密码名称,长度不能超过20个字符
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
/**
|
|
60
|
+
* 密码生效开始时间,单位为秒
|
|
61
|
+
*/
|
|
62
|
+
effectiveTime: number;
|
|
63
|
+
/**
|
|
64
|
+
* 密码生效结束时间,单位为秒
|
|
65
|
+
*/
|
|
66
|
+
invalidTime: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 创建临时限时密码
|
|
70
|
+
*/
|
|
71
|
+
export declare const createTempLimit: (params: CreateLimitParams) => Promise<TempPasswordResult>;
|
|
72
|
+
interface CreateOnceParams {
|
|
73
|
+
/**
|
|
74
|
+
* 密码名称,长度不能超过20个字符
|
|
75
|
+
*/
|
|
76
|
+
name?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 创建一次性密码
|
|
80
|
+
* @param {CreateOnceParams} params - 创建一次性密码的参数
|
|
81
|
+
* @returns {Promise<OfflinePwdResult>} - 返回创建结果
|
|
82
|
+
* @throws {ErrorData} - 如果创建失败,将抛出错误
|
|
83
|
+
*/
|
|
84
|
+
export declare const createTempOnce: (params: CreateOnceParams) => Promise<TempPasswordResult>;
|
|
85
|
+
/**
|
|
86
|
+
* 创建动态密码
|
|
87
|
+
*/
|
|
88
|
+
export declare const createTempDynamic: () => Promise<TempPasswordResult>;
|
|
89
|
+
interface CreateClearParams {
|
|
90
|
+
name?: string;
|
|
91
|
+
unlockBindingId?: string;
|
|
92
|
+
clearAll: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 生成清除密码
|
|
96
|
+
* 可支持清除所有或某个限时密码
|
|
97
|
+
* @param {CreateClearParams} params
|
|
98
|
+
* @returns {Promise<OfflinePwdResult>} - 返回清除密码结果
|
|
99
|
+
* @throws {ErrorData} - 如果生成清除密码失败,将抛出错误
|
|
100
|
+
*/
|
|
101
|
+
export declare const createTempClear: (params: CreateClearParams) => Promise<TempPasswordResult>;
|
|
102
|
+
/**
|
|
103
|
+
* 临时密码的状态
|
|
104
|
+
* effective - 生效
|
|
105
|
+
* toBeEffective - 待生效
|
|
106
|
+
* expired - 已失效
|
|
107
|
+
* frozen - 冻结
|
|
108
|
+
* freezing - 冻结中
|
|
109
|
+
* synchronizing - 同步中
|
|
110
|
+
* synchronized - 已同步
|
|
111
|
+
* deleted - 已删除
|
|
112
|
+
* toBeDeleted - 待删除
|
|
113
|
+
* synchronizationFailed - 同步失败
|
|
114
|
+
*/
|
|
115
|
+
type ValidPasswordStatus = "effective" | "toBeEffective" | "frozen" | "freezing" | "synchronizing" | "toBeDeleted";
|
|
116
|
+
/**
|
|
117
|
+
*密码的无效原因
|
|
118
|
+
* synchronizationFailed - 同步失败
|
|
119
|
+
* passwordFull - 密码已满
|
|
120
|
+
* deleted - 已删除
|
|
121
|
+
*/
|
|
122
|
+
type InvalidReason = "synchronizationFailed" | "passwordFull" | "deleted";
|
|
123
|
+
interface PasswrodBaseInfo {
|
|
124
|
+
/**
|
|
125
|
+
* 解锁绑定 ID
|
|
126
|
+
*/
|
|
127
|
+
unlockBindingId: string;
|
|
128
|
+
/**
|
|
129
|
+
* 生效配置
|
|
130
|
+
*/
|
|
131
|
+
effectiveConfig: EffectiveConfig;
|
|
132
|
+
/**
|
|
133
|
+
* 密码名称
|
|
134
|
+
*/
|
|
135
|
+
name: string;
|
|
136
|
+
/**
|
|
137
|
+
* 密码类型
|
|
138
|
+
* "custom" - 自定义密码
|
|
139
|
+
* "once" - 一次性密码
|
|
140
|
+
* "limit" - 限时密码
|
|
141
|
+
* "clear" - 清除密码
|
|
142
|
+
* "clearOne" - 清除单个密码
|
|
143
|
+
*/
|
|
144
|
+
type: TemporaryPasswordType;
|
|
145
|
+
/**
|
|
146
|
+
* 密码 sn
|
|
147
|
+
*/
|
|
148
|
+
sn: number;
|
|
149
|
+
/**
|
|
150
|
+
* 当前密码是否被标记被清除
|
|
151
|
+
*/
|
|
152
|
+
hasClearPwd: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* 清除单个密码的信息
|
|
155
|
+
* 密码类型为 "clearOne" 时有效
|
|
156
|
+
*/
|
|
157
|
+
clearInfo?: {
|
|
158
|
+
/**
|
|
159
|
+
* 单个密码名称
|
|
160
|
+
*/
|
|
161
|
+
name: string;
|
|
162
|
+
/**
|
|
163
|
+
* 单个密码生效配置
|
|
164
|
+
*/
|
|
165
|
+
effectiveConfig: EffectiveConfig;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export interface EffectivePasswrodItem extends PasswrodBaseInfo {
|
|
169
|
+
/**
|
|
170
|
+
* 密码状态
|
|
171
|
+
*/
|
|
172
|
+
status: ValidPasswordStatus;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 获取有效的临时密码列表
|
|
176
|
+
*/
|
|
177
|
+
export declare const getTempEffectiveList: () => Promise<EffectivePasswrodItem[]>;
|
|
178
|
+
export interface InvalidPasswordItem extends PasswrodBaseInfo {
|
|
179
|
+
status: "expired";
|
|
180
|
+
invalidReason: InvalidReason;
|
|
181
|
+
}
|
|
182
|
+
interface GetInvalidListParams {
|
|
183
|
+
/**
|
|
184
|
+
* 分页
|
|
185
|
+
*/
|
|
186
|
+
page?: number;
|
|
187
|
+
/**
|
|
188
|
+
* 每页记录数
|
|
189
|
+
* 默认值为 200
|
|
190
|
+
*/
|
|
191
|
+
pageSize?: number;
|
|
192
|
+
}
|
|
193
|
+
export declare const getTempInvalidList: (params?: GetInvalidListParams) => Promise<{
|
|
194
|
+
list: InvalidPasswordItem[];
|
|
195
|
+
hasMore: boolean;
|
|
196
|
+
total: number;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* 清空无效的临时密码列表
|
|
200
|
+
*/
|
|
201
|
+
export declare const clearTempInvalidList: () => Promise<boolean>;
|
|
202
|
+
interface FreezeParams {
|
|
203
|
+
unlockBindingId: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 冻结临时密码
|
|
207
|
+
* @param params
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
export declare const freezeTemp: (params: FreezeParams) => Promise<boolean>;
|
|
211
|
+
/**
|
|
212
|
+
* 解冻临时密码
|
|
213
|
+
* @param params
|
|
214
|
+
* @returns
|
|
215
|
+
*/
|
|
216
|
+
export declare const unfreezeTemp: (params: FreezeParams) => Promise<boolean>;
|
|
217
|
+
interface RenameParams {
|
|
218
|
+
unlockBindingId: string;
|
|
219
|
+
name: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* 重命名密码名称
|
|
223
|
+
* @param {RenameParams} params
|
|
224
|
+
*/
|
|
225
|
+
export declare const renameTemp: (params: RenameParams) => Promise<void>;
|
|
226
|
+
export {};
|