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