@ray-js/lock-sdk 1.0.1-beta-2 → 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
package/lib/temporary.js
CHANGED
|
@@ -1,637 +1,513 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
-
import "core-js/modules/esnext.iterator.find.js";
|
|
4
|
-
import "core-js/modules/esnext.iterator.map.js";
|
|
5
|
-
import { clearInvalidTempList, createOfflinePassword, createTemporaryPassword, deleteTempPassword, fetchEffectiveList, fetchInvalidList, getDynamicPassword, reNameOffline, reNameTemporary, revokeOfflinePassword, updateTemporaryPassword, validateTempPwd } from "./api/temp";
|
|
1
|
+
import { clearInvalidTempList, createOfflinePassword, createTemporaryPassword, deleteTempPassword, fetchEffectiveList, fetchInvalidList, getDynamicPassword, reNameOffline, reNameTemporary, revokeOfflinePassword, updateTemporaryPassword, validateTempPwd, } from "./api/temp";
|
|
6
2
|
import config from "./config";
|
|
7
|
-
import { formatWeek, isUseNearChannel, parallelOnly, parseOfflinePassword, parseWeek, validateEffectiveConfig } from "./utils";
|
|
3
|
+
import { formatWeek, isUseNearChannel, parallelOnly, parseOfflinePassword, parseWeek, validateEffectiveConfig, } from "./utils";
|
|
8
4
|
import { LoopTypes } from "./utils/constant";
|
|
9
5
|
import { encrypt } from "./utils/device";
|
|
10
6
|
import { getError } from "./utils/errors";
|
|
11
|
-
import { addTempPwd as addTempPwdDpMap, reportAddTempPwd as reportAddTempPwdDpMap } from "./config/dp-map/unlock-method";
|
|
12
|
-
import { addTempPwd as addTempPwdBigDpMap, reportAddTempPwd as reportAddTempPwdDBigpMap } from "./config/dp-map/unlock-method-big";
|
|
7
|
+
import { addTempPwd as addTempPwdDpMap, reportAddTempPwd as reportAddTempPwdDpMap, } from "./config/dp-map/unlock-method";
|
|
8
|
+
import { addTempPwd as addTempPwdBigDpMap, reportAddTempPwd as reportAddTempPwdDBigpMap, } from "./config/dp-map/unlock-method-big";
|
|
13
9
|
import { publishDps } from "./utils/publishDps";
|
|
14
10
|
import dpCodes from "./config/dp-code";
|
|
15
11
|
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
16
12
|
const PASSWORD_REGEX = /^[0-9]+$/;
|
|
17
|
-
const handleError = cloudError => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const handleError = (cloudError) => {
|
|
14
|
+
switch (cloudError.errorCode) {
|
|
15
|
+
case "USER_PWD_ALREADY_EXIST":
|
|
16
|
+
throw getError(1037);
|
|
17
|
+
case "LOCK_PWD_NAME_REPEAT":
|
|
18
|
+
throw getError(1038);
|
|
19
|
+
case "START_END_DATE_NOT_RIGHT":
|
|
20
|
+
throw getError(1039);
|
|
21
|
+
case "RECORD_NOT_EXIST":
|
|
22
|
+
throw getError(1040);
|
|
23
|
+
default:
|
|
24
|
+
throw cloudError;
|
|
25
|
+
}
|
|
30
26
|
};
|
|
31
|
-
const isValidPassword = async params => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return true;
|
|
27
|
+
const isValidPassword = async (params) => {
|
|
28
|
+
const validateResult = await validateTempPwd(params);
|
|
29
|
+
if (!validateResult.valid) {
|
|
30
|
+
handleError(validateResult);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
38
33
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export const createTempCustom = parallelOnly(async params => {
|
|
47
|
-
var _effective$repeat, _effective$weeks;
|
|
48
|
-
const {
|
|
49
|
-
password,
|
|
50
|
-
name,
|
|
51
|
-
effective
|
|
52
|
-
} = params;
|
|
53
|
-
// 密码的校验,仅做简单的数字校验
|
|
54
|
-
if (!PASSWORD_REGEX.test(password)) {
|
|
55
|
-
throw getError(1030);
|
|
56
|
-
}
|
|
57
|
-
// 名称的校验,长度不能超过20个字符
|
|
58
|
-
if (name && name.length > 20) {
|
|
59
|
-
throw getError(1031);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 时效校验
|
|
63
|
-
validateEffectiveConfig(effective);
|
|
64
|
-
const {
|
|
65
|
-
effectiveTime = 0,
|
|
66
|
-
expiredTime = 1439
|
|
67
|
-
} = effective;
|
|
68
|
-
const useNear = isUseNearChannel();
|
|
69
|
-
const aesPwd = await encrypt(config.devInfo.devId, password);
|
|
70
|
-
// 循环方式
|
|
71
|
-
const loopType = effective !== null && effective !== void 0 && effective.repeat ?
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
LoopTypes[effective === null || effective === void 0 || (_effective$repeat = effective.repeat) === null || _effective$repeat === void 0 ? void 0 : _effective$repeat.toUpperCase()] : LoopTypes.NONE;
|
|
74
|
-
const schedule = [{
|
|
75
|
-
allDay: loopType === LoopTypes.NONE,
|
|
76
|
-
effectiveTime,
|
|
77
|
-
invalidTime: expiredTime,
|
|
78
|
-
workingDay: formatWeek((_effective$weeks = effective === null || effective === void 0 ? void 0 : effective.weeks) !== null && _effective$weeks !== void 0 ? _effective$weeks : [0])
|
|
79
|
-
}];
|
|
80
|
-
const baseData = {
|
|
81
|
-
devId: config.devInfo.devId,
|
|
82
|
-
effectiveTime: effective.effectiveDate,
|
|
83
|
-
invalidTime: effective.expiredDate,
|
|
84
|
-
name: name,
|
|
85
|
-
password: aesPwd,
|
|
86
|
-
schedule
|
|
87
|
-
};
|
|
88
|
-
if (useNear) {
|
|
89
|
-
var _effective$weeks2;
|
|
90
|
-
// 走蓝牙通道
|
|
91
|
-
await isValidPassword(baseData);
|
|
92
|
-
const {
|
|
93
|
-
tyNum,
|
|
94
|
-
name
|
|
95
|
-
} = await createTemporaryPassword(_objectSpread(_objectSpread({}, baseData), {}, {
|
|
96
|
-
sn: 0,
|
|
97
|
-
availTime: 0,
|
|
98
|
-
symbolic: false,
|
|
99
|
-
dpTunnel: 2
|
|
100
|
-
}));
|
|
101
|
-
if (!tyNum) {
|
|
102
|
-
throw getError(1043);
|
|
34
|
+
export const createTempCustom = parallelOnly(async (params) => {
|
|
35
|
+
const { password, name, effective } = params;
|
|
36
|
+
if (!PASSWORD_REGEX.test(password)) {
|
|
37
|
+
throw getError(1030);
|
|
38
|
+
}
|
|
39
|
+
if (name && name.length > 20) {
|
|
40
|
+
throw getError(1031);
|
|
103
41
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
42
|
+
validateEffectiveConfig(effective);
|
|
43
|
+
const { effectiveTime = 0, expiredTime = 1439 } = effective;
|
|
44
|
+
const useNear = isUseNearChannel();
|
|
45
|
+
const aesPwd = await encrypt(config.devInfo.devId, password);
|
|
46
|
+
const loopType = effective?.repeat
|
|
47
|
+
?
|
|
48
|
+
LoopTypes[effective?.repeat?.toUpperCase()]
|
|
49
|
+
: LoopTypes.NONE;
|
|
50
|
+
const schedule = [
|
|
51
|
+
{
|
|
52
|
+
allDay: loopType === LoopTypes.NONE,
|
|
53
|
+
effectiveTime,
|
|
54
|
+
invalidTime: expiredTime,
|
|
55
|
+
workingDay: formatWeek(effective?.weeks ?? [0]),
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
const baseData = {
|
|
59
|
+
devId: config.devInfo.devId,
|
|
60
|
+
effectiveTime: effective.effectiveDate,
|
|
61
|
+
invalidTime: effective.expiredDate,
|
|
62
|
+
name: name,
|
|
63
|
+
password: aesPwd,
|
|
64
|
+
schedule,
|
|
124
65
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
66
|
+
if (useNear) {
|
|
67
|
+
await isValidPassword(baseData);
|
|
68
|
+
const { tyNum, name } = await createTemporaryPassword({
|
|
69
|
+
...baseData,
|
|
70
|
+
sn: 0,
|
|
71
|
+
availTime: 0,
|
|
72
|
+
symbolic: false,
|
|
73
|
+
dpTunnel: 2,
|
|
74
|
+
});
|
|
75
|
+
if (!tyNum) {
|
|
76
|
+
throw getError(1043);
|
|
136
77
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
78
|
+
const dpData = {
|
|
79
|
+
cloudNo: tyNum,
|
|
80
|
+
valid: true,
|
|
81
|
+
validConfig: {
|
|
82
|
+
startTime: effective.effectiveDate,
|
|
83
|
+
endTime: effective.expiredDate,
|
|
84
|
+
loop: loopType,
|
|
85
|
+
loopConfig: 0,
|
|
86
|
+
weeks: effective.weeks ?? [0, 0, 0, 0, 0, 0, 0],
|
|
87
|
+
days: [],
|
|
88
|
+
startHour: Math.floor(effectiveTime / 60),
|
|
89
|
+
startMinute: effectiveTime % 60,
|
|
90
|
+
endHour: Math.floor(expiredTime / 60),
|
|
91
|
+
endMinute: expiredTime % 60,
|
|
92
|
+
},
|
|
93
|
+
validNum: 0,
|
|
94
|
+
pwdLength: params.password.length,
|
|
95
|
+
pwd: params.password.split("").map(Number),
|
|
96
|
+
};
|
|
97
|
+
const targetDpCode = config.supportBigData
|
|
98
|
+
? dpCodes.tempPwdCreateW
|
|
99
|
+
: dpCodes.tempPwdCreate;
|
|
100
|
+
const result = await publishDps({
|
|
101
|
+
[targetDpCode]: dpUtils.format(dpData, (config.supportBigData
|
|
102
|
+
? addTempPwdBigDpMap
|
|
103
|
+
: addTempPwdDpMap)),
|
|
104
|
+
}, {
|
|
105
|
+
checkReport: (dpData) => {
|
|
106
|
+
const reportData = dpData[targetDpCode];
|
|
107
|
+
if (reportData) {
|
|
108
|
+
const data = dpUtils.parse(dpData[targetDpCode], (config.supportBigData
|
|
109
|
+
? reportAddTempPwdDBigpMap
|
|
110
|
+
: reportAddTempPwdDpMap));
|
|
111
|
+
if (data.cloudNo === tyNum) {
|
|
112
|
+
return data;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
if (result.status === 0) {
|
|
119
|
+
return {
|
|
120
|
+
type: "custom",
|
|
121
|
+
name: name,
|
|
122
|
+
password: password,
|
|
123
|
+
unlockBindingId: result.unlockBindingId,
|
|
124
|
+
effectiveConfig: effective,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
throw getError(result.status === 2 ? 1041 : 1042);
|
|
148
128
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
129
|
+
else {
|
|
130
|
+
try {
|
|
131
|
+
const res = await createTemporaryPassword({
|
|
132
|
+
...baseData,
|
|
133
|
+
sn: 0,
|
|
134
|
+
availTime: 0,
|
|
135
|
+
symbolic: false,
|
|
136
|
+
dpTunnel: 2,
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
type: "custom",
|
|
140
|
+
name: res.name,
|
|
141
|
+
password: password,
|
|
142
|
+
unlockBindingId: res.unlockBindingId,
|
|
143
|
+
effectiveConfig: effective,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw handleError(error);
|
|
148
|
+
}
|
|
168
149
|
}
|
|
169
|
-
}
|
|
170
150
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
devId: config.devInfo.devId,
|
|
180
|
-
unlockBindingId: params.unlockBindingId,
|
|
181
|
-
symbolic: false,
|
|
182
|
-
dpTunnel: 2
|
|
183
|
-
});
|
|
184
|
-
} catch (e) {
|
|
185
|
-
handleError(e);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* 更新自定义临时密码
|
|
190
|
-
* 注意,当前只支持更新名称和时效配置,且只支持走云端更新。
|
|
191
|
-
* @param {UpdateTempPasswordParams} params 更新临时密码的参数
|
|
192
|
-
* @returns {Promise<void>} - 返回更新结果
|
|
193
|
-
* @throws {ErrorData} - 如果更新失败,将抛出错误
|
|
194
|
-
*/
|
|
195
|
-
export const updateTempCustom = async params => {
|
|
196
|
-
var _effective$repeat2, _effective$effectiveT, _effective$expiredTim, _effective$weeks3;
|
|
197
|
-
const {
|
|
198
|
-
unlockBindingId,
|
|
199
|
-
name,
|
|
200
|
-
effective
|
|
201
|
-
} = params;
|
|
202
|
-
|
|
203
|
-
// 名称的校验,长度不能超过20个字符
|
|
204
|
-
if (name && name.length > 20) {
|
|
205
|
-
throw getError(1031);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 时效校验
|
|
209
|
-
validateEffectiveConfig(effective);
|
|
210
|
-
// 循环方式
|
|
211
|
-
const loopType = effective !== null && effective !== void 0 && effective.repeat ?
|
|
212
|
-
// @ts-ignore
|
|
213
|
-
LoopTypes[effective === null || effective === void 0 || (_effective$repeat2 = effective.repeat) === null || _effective$repeat2 === void 0 ? void 0 : _effective$repeat2.toUpperCase()] : LoopTypes.NONE;
|
|
214
|
-
const schedule = [{
|
|
215
|
-
allDay: loopType === LoopTypes.NONE,
|
|
216
|
-
effectiveTime: (_effective$effectiveT = effective === null || effective === void 0 ? void 0 : effective.effectiveTime) !== null && _effective$effectiveT !== void 0 ? _effective$effectiveT : 0,
|
|
217
|
-
invalidTime: (_effective$expiredTim = effective === null || effective === void 0 ? void 0 : effective.expiredTime) !== null && _effective$expiredTim !== void 0 ? _effective$expiredTim : 0,
|
|
218
|
-
workingDay: formatWeek((_effective$weeks3 = effective === null || effective === void 0 ? void 0 : effective.weeks) !== null && _effective$weeks3 !== void 0 ? _effective$weeks3 : [0])
|
|
219
|
-
}];
|
|
220
|
-
try {
|
|
221
|
-
return updateTemporaryPassword({
|
|
222
|
-
devId: config.devInfo.devId,
|
|
223
|
-
effectiveTime: effective.effectiveDate,
|
|
224
|
-
invalidTime: effective.expiredDate,
|
|
225
|
-
name: name,
|
|
226
|
-
schedule,
|
|
227
|
-
unlockBindingId,
|
|
228
|
-
symbolic: false,
|
|
229
|
-
dpTunnel: 2
|
|
230
|
-
});
|
|
231
|
-
} catch (error) {
|
|
232
|
-
handleError(error);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
const getOfflinePassword = async params => {
|
|
236
|
-
try {
|
|
237
|
-
// 获取密码
|
|
238
|
-
const res = await createOfflinePassword(params);
|
|
239
|
-
return _objectSpread(_objectSpread({}, res), {}, {
|
|
240
|
-
pwd: parseOfflinePassword(res.pwd)
|
|
241
|
-
});
|
|
242
|
-
} catch (error) {
|
|
243
|
-
throw handleError(error);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* 创建临时限时密码
|
|
249
|
-
*/
|
|
250
|
-
export const createTempLimit = async params => {
|
|
251
|
-
const {
|
|
252
|
-
name,
|
|
253
|
-
effectiveTime,
|
|
254
|
-
invalidTime
|
|
255
|
-
} = params;
|
|
256
|
-
// 名称的校验,长度不能超过20个字符
|
|
257
|
-
if (name && name.length > 20) {
|
|
258
|
-
throw getError(1031);
|
|
259
|
-
}
|
|
260
|
-
// 生效时间校验
|
|
261
|
-
if (effectiveTime >= invalidTime) {
|
|
262
|
-
throw getError(1010);
|
|
263
|
-
}
|
|
264
|
-
const res = await getOfflinePassword({
|
|
265
|
-
devId: config.devInfo.devId,
|
|
266
|
-
pwdType: "0",
|
|
267
|
-
pwdName: name,
|
|
268
|
-
gmtStart: effectiveTime,
|
|
269
|
-
gmtExpired: invalidTime
|
|
270
|
-
});
|
|
271
|
-
return {
|
|
272
|
-
type: "limit",
|
|
273
|
-
name: res.pwdName,
|
|
274
|
-
password: parseOfflinePassword(res.pwd),
|
|
275
|
-
unlockBindingId: res.unlockBindingId,
|
|
276
|
-
effectiveConfig: {
|
|
277
|
-
effectiveDate: res.gmtStart,
|
|
278
|
-
expiredDate: res.gmtExpired
|
|
151
|
+
export const removeTempCustom = async (params) => {
|
|
152
|
+
try {
|
|
153
|
+
return deleteTempPassword({
|
|
154
|
+
devId: config.devInfo.devId,
|
|
155
|
+
unlockBindingId: params.unlockBindingId,
|
|
156
|
+
symbolic: false,
|
|
157
|
+
dpTunnel: 2,
|
|
158
|
+
});
|
|
279
159
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* 创建一次性密码
|
|
284
|
-
* @param {CreateOnceParams} params - 创建一次性密码的参数
|
|
285
|
-
* @returns {Promise<OfflinePwdResult>} - 返回创建结果
|
|
286
|
-
* @throws {ErrorData} - 如果创建失败,将抛出错误
|
|
287
|
-
*/
|
|
288
|
-
export const createTempOnce = async params => {
|
|
289
|
-
const {
|
|
290
|
-
name
|
|
291
|
-
} = params;
|
|
292
|
-
// 名称的校验,长度不能超过20个字符
|
|
293
|
-
if (name && name.length > 20) {
|
|
294
|
-
throw getError(1031);
|
|
295
|
-
}
|
|
296
|
-
const res = await getOfflinePassword({
|
|
297
|
-
devId: config.devInfo.devId,
|
|
298
|
-
pwdType: "1",
|
|
299
|
-
pwdName: name,
|
|
300
|
-
gmtStart: 0,
|
|
301
|
-
gmtExpired: 0
|
|
302
|
-
});
|
|
303
|
-
return {
|
|
304
|
-
type: "once",
|
|
305
|
-
name: res.pwdName,
|
|
306
|
-
password: parseOfflinePassword(res.pwd),
|
|
307
|
-
unlockBindingId: res.unlockBindingId,
|
|
308
|
-
effectiveConfig: {
|
|
309
|
-
effectiveDate: res.gmtStart,
|
|
310
|
-
expiredDate: res.gmtExpired
|
|
160
|
+
catch (e) {
|
|
161
|
+
handleError(e);
|
|
311
162
|
}
|
|
312
|
-
};
|
|
313
163
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
export const createTempDynamic = async () => {
|
|
319
|
-
const {
|
|
320
|
-
dynamicPassword
|
|
321
|
-
} = await getDynamicPassword({
|
|
322
|
-
devId: config.devInfo.devId
|
|
323
|
-
});
|
|
324
|
-
const now = Math.floor(Date.now() / 1000);
|
|
325
|
-
return {
|
|
326
|
-
type: "dynamic",
|
|
327
|
-
name: "",
|
|
328
|
-
// 动态密码无名称
|
|
329
|
-
password: parseOfflinePassword(dynamicPassword),
|
|
330
|
-
unlockBindingId: "",
|
|
331
|
-
// 动态密码无解锁绑定 ID
|
|
332
|
-
effectiveConfig: {
|
|
333
|
-
effectiveDate: now,
|
|
334
|
-
// 动态密码生效时间为当前时间
|
|
335
|
-
expiredDate: now + 5 * 60 // 动态密码有效期为5分钟
|
|
164
|
+
export const updateTempCustom = async (params) => {
|
|
165
|
+
const { unlockBindingId, name, effective } = params;
|
|
166
|
+
if (name && name.length > 20) {
|
|
167
|
+
throw getError(1031);
|
|
336
168
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
gmtStart: 0,
|
|
365
|
-
gmtExpired: 0
|
|
366
|
-
});
|
|
367
|
-
} else {
|
|
368
|
-
res = await revokeOfflinePassword({
|
|
369
|
-
devId: config.devInfo.devId,
|
|
370
|
-
name,
|
|
371
|
-
unlockBindingId: unlockBindingId
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
return {
|
|
375
|
-
type: clearAll ? "clear" : "clearOne",
|
|
376
|
-
name: res.pwdName,
|
|
377
|
-
password: parseOfflinePassword(res.pwd),
|
|
378
|
-
unlockBindingId: res.unlockBindingId,
|
|
379
|
-
effectiveConfig: {
|
|
380
|
-
effectiveDate: res.gmtStart,
|
|
381
|
-
expiredDate: res.gmtExpired
|
|
169
|
+
validateEffectiveConfig(effective);
|
|
170
|
+
const loopType = effective?.repeat
|
|
171
|
+
?
|
|
172
|
+
LoopTypes[effective?.repeat?.toUpperCase()]
|
|
173
|
+
: LoopTypes.NONE;
|
|
174
|
+
const schedule = [
|
|
175
|
+
{
|
|
176
|
+
allDay: loopType === LoopTypes.NONE,
|
|
177
|
+
effectiveTime: effective?.effectiveTime ?? 0,
|
|
178
|
+
invalidTime: effective?.expiredTime ?? 0,
|
|
179
|
+
workingDay: formatWeek(effective?.weeks ?? [0]),
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
try {
|
|
183
|
+
return updateTemporaryPassword({
|
|
184
|
+
devId: config.devInfo.devId,
|
|
185
|
+
effectiveTime: effective.effectiveDate,
|
|
186
|
+
invalidTime: effective.expiredDate,
|
|
187
|
+
name: name,
|
|
188
|
+
schedule,
|
|
189
|
+
unlockBindingId,
|
|
190
|
+
symbolic: false,
|
|
191
|
+
dpTunnel: 2,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
handleError(error);
|
|
382
196
|
}
|
|
383
|
-
};
|
|
384
197
|
};
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
* toBeDeleted - 待删除
|
|
397
|
-
* synchronizationFailed - 同步失败
|
|
398
|
-
*/
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
*密码的无效原因
|
|
402
|
-
* synchronizationFailed - 同步失败
|
|
403
|
-
* passwordFull - 密码已满
|
|
404
|
-
* deleted - 已删除
|
|
405
|
-
*/
|
|
406
|
-
|
|
407
|
-
const passwordTypeMap = {
|
|
408
|
-
"1-0": "custom",
|
|
409
|
-
"3-1": "once",
|
|
410
|
-
"3-0": "limit",
|
|
411
|
-
"3-8": "clearOne",
|
|
412
|
-
"3-9": "clear"
|
|
198
|
+
const getOfflinePassword = async (params) => {
|
|
199
|
+
try {
|
|
200
|
+
const res = await createOfflinePassword(params);
|
|
201
|
+
return {
|
|
202
|
+
...res,
|
|
203
|
+
pwd: parseOfflinePassword(res.pwd),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
throw handleError(error);
|
|
208
|
+
}
|
|
413
209
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
export const getTempEffectiveList = async () => {
|
|
419
|
-
const res = await fetchEffectiveList({
|
|
420
|
-
devId: config.devInfo.devId,
|
|
421
|
-
authTypes: ["LOCK_OFFLINE_TEMP_PWD", "LOCK_TEMP_PWD"]
|
|
422
|
-
});
|
|
423
|
-
return res.map(item => {
|
|
424
|
-
var _item$scheduleDetails, _item$opModeInfo;
|
|
425
|
-
// 类型
|
|
426
|
-
const type = passwordTypeMap[`${item.opModeType}-${item.opModeSubType}`] || "custom";
|
|
427
|
-
// 状态
|
|
428
|
-
let status = "toBeEffective"; // 默认状态为未生效
|
|
429
|
-
if (item.effective !== 1) {
|
|
430
|
-
switch (item.phase) {
|
|
431
|
-
case 1:
|
|
432
|
-
status = "effective"; // 生效中
|
|
433
|
-
break;
|
|
434
|
-
case 2:
|
|
435
|
-
status = "synchronizing"; // 同步中
|
|
436
|
-
break;
|
|
437
|
-
case 3:
|
|
438
|
-
status = "frozen"; // 已冻结
|
|
439
|
-
break;
|
|
440
|
-
case 4:
|
|
441
|
-
status = "freezing"; // 冻结中
|
|
442
|
-
break;
|
|
443
|
-
case 9:
|
|
444
|
-
status = "toBeDeleted"; // 待删除
|
|
445
|
-
break;
|
|
446
|
-
case 10:
|
|
447
|
-
status = "synchronizing"; // 同步中
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
210
|
+
export const createTempLimit = async (params) => {
|
|
211
|
+
const { name, effectiveTime, invalidTime } = params;
|
|
212
|
+
if (name && name.length > 20) {
|
|
213
|
+
throw getError(1031);
|
|
450
214
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
215
|
+
if (effectiveTime >= invalidTime) {
|
|
216
|
+
throw getError(1010);
|
|
217
|
+
}
|
|
218
|
+
const res = await getOfflinePassword({
|
|
219
|
+
devId: config.devInfo.devId,
|
|
220
|
+
pwdType: "0",
|
|
221
|
+
pwdName: name,
|
|
222
|
+
gmtStart: effectiveTime,
|
|
223
|
+
gmtExpired: invalidTime,
|
|
224
|
+
});
|
|
225
|
+
return {
|
|
226
|
+
type: "limit",
|
|
227
|
+
name: res.pwdName,
|
|
228
|
+
password: parseOfflinePassword(res.pwd),
|
|
229
|
+
unlockBindingId: res.unlockBindingId,
|
|
230
|
+
effectiveConfig: {
|
|
231
|
+
effectiveDate: res.gmtStart,
|
|
232
|
+
expiredDate: res.gmtExpired,
|
|
233
|
+
},
|
|
454
234
|
};
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
effectiveConfig.effectiveTime = scheduleDetail.effectiveTime;
|
|
461
|
-
effectiveConfig.expiredTime = scheduleDetail.invalidTime;
|
|
462
|
-
}
|
|
235
|
+
};
|
|
236
|
+
export const createTempOnce = async (params) => {
|
|
237
|
+
const { name } = params;
|
|
238
|
+
if (name && name.length > 20) {
|
|
239
|
+
throw getError(1031);
|
|
463
240
|
}
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
241
|
+
const res = await getOfflinePassword({
|
|
242
|
+
devId: config.devInfo.devId,
|
|
243
|
+
pwdType: "1",
|
|
244
|
+
pwdName: name,
|
|
245
|
+
gmtStart: 0,
|
|
246
|
+
gmtExpired: 0,
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
type: "once",
|
|
250
|
+
name: res.pwdName,
|
|
251
|
+
password: parseOfflinePassword(res.pwd),
|
|
252
|
+
unlockBindingId: res.unlockBindingId,
|
|
253
|
+
effectiveConfig: {
|
|
254
|
+
effectiveDate: res.gmtStart,
|
|
255
|
+
expiredDate: res.gmtExpired,
|
|
256
|
+
},
|
|
472
257
|
};
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
258
|
+
};
|
|
259
|
+
export const createTempDynamic = async () => {
|
|
260
|
+
const { dynamicPassword } = await getDynamicPassword({
|
|
261
|
+
devId: config.devInfo.devId,
|
|
262
|
+
});
|
|
263
|
+
const now = Math.floor(Date.now() / 1000);
|
|
264
|
+
return {
|
|
265
|
+
type: "dynamic",
|
|
266
|
+
name: "",
|
|
267
|
+
password: parseOfflinePassword(dynamicPassword),
|
|
268
|
+
unlockBindingId: "",
|
|
477
269
|
effectiveConfig: {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
return data;
|
|
484
|
-
});
|
|
270
|
+
effectiveDate: now,
|
|
271
|
+
expiredDate: now + 5 * 60,
|
|
272
|
+
},
|
|
273
|
+
};
|
|
485
274
|
};
|
|
486
|
-
export const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
limit: (params === null || params === void 0 ? void 0 : params.pageSize) || 200
|
|
491
|
-
});
|
|
492
|
-
const list = res.datas.map(item => {
|
|
493
|
-
var _item$scheduleDetails2, _item$opModeInfo5;
|
|
494
|
-
// 类型
|
|
495
|
-
const type = passwordTypeMap[`${item.opModeType}-${item.opModeSubType}`] || "custom";
|
|
496
|
-
// 状态
|
|
497
|
-
|
|
498
|
-
// 默认状态为未生效
|
|
499
|
-
let invalidReason = "synchronizationFailed"; // 默认失败原因为已删除
|
|
500
|
-
if (item.phase === 8) {
|
|
501
|
-
invalidReason = "deleted"; // 已删除
|
|
275
|
+
export const createTempClear = async (params) => {
|
|
276
|
+
const { name, unlockBindingId, clearAll } = params;
|
|
277
|
+
if (name && name.length > 20) {
|
|
278
|
+
throw getError(1031);
|
|
502
279
|
}
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
case 1:
|
|
506
|
-
invalidReason = "synchronizationFailed"; // 生效中
|
|
507
|
-
break;
|
|
508
|
-
case 2:
|
|
509
|
-
invalidReason = "passwordFull"; // 密码已满
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
280
|
+
if (!clearAll && !unlockBindingId) {
|
|
281
|
+
throw getError(1044);
|
|
512
282
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
effectiveConfig.effectiveTime = scheduleDetail.effectiveTime;
|
|
523
|
-
effectiveConfig.expiredTime = scheduleDetail.invalidTime;
|
|
524
|
-
}
|
|
283
|
+
let res;
|
|
284
|
+
if (clearAll) {
|
|
285
|
+
res = await getOfflinePassword({
|
|
286
|
+
devId: config.devInfo.devId,
|
|
287
|
+
pwdType: "9",
|
|
288
|
+
pwdName: name,
|
|
289
|
+
gmtStart: 0,
|
|
290
|
+
gmtExpired: 0,
|
|
291
|
+
});
|
|
525
292
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
data.clearInfo = {
|
|
539
|
-
name: ((_item$opModeInfo6 = item.opModeInfo) === null || _item$opModeInfo6 === void 0 ? void 0 : _item$opModeInfo6.revokedPwdName) || "",
|
|
293
|
+
else {
|
|
294
|
+
res = await revokeOfflinePassword({
|
|
295
|
+
devId: config.devInfo.devId,
|
|
296
|
+
name,
|
|
297
|
+
unlockBindingId: unlockBindingId,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
type: clearAll ? "clear" : "clearOne",
|
|
302
|
+
name: res.pwdName,
|
|
303
|
+
password: parseOfflinePassword(res.pwd),
|
|
304
|
+
unlockBindingId: res.unlockBindingId,
|
|
540
305
|
effectiveConfig: {
|
|
541
|
-
|
|
542
|
-
|
|
306
|
+
effectiveDate: res.gmtStart,
|
|
307
|
+
expiredDate: res.gmtExpired,
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
const passwordTypeMap = {
|
|
312
|
+
"1-0": "custom",
|
|
313
|
+
"3-1": "once",
|
|
314
|
+
"3-0": "limit",
|
|
315
|
+
"3-8": "clearOne",
|
|
316
|
+
"3-9": "clear",
|
|
317
|
+
};
|
|
318
|
+
export const getTempEffectiveList = async () => {
|
|
319
|
+
const res = await fetchEffectiveList({
|
|
320
|
+
devId: config.devInfo.devId,
|
|
321
|
+
authTypes: ["LOCK_OFFLINE_TEMP_PWD", "LOCK_TEMP_PWD"],
|
|
322
|
+
});
|
|
323
|
+
return res.map((item) => {
|
|
324
|
+
const type = passwordTypeMap[`${item.opModeType}-${item.opModeSubType}`] || "custom";
|
|
325
|
+
let status = "toBeEffective";
|
|
326
|
+
if (item.effective !== 1) {
|
|
327
|
+
switch (item.phase) {
|
|
328
|
+
case 1:
|
|
329
|
+
status = "effective";
|
|
330
|
+
break;
|
|
331
|
+
case 2:
|
|
332
|
+
status = "synchronizing";
|
|
333
|
+
break;
|
|
334
|
+
case 3:
|
|
335
|
+
status = "frozen";
|
|
336
|
+
break;
|
|
337
|
+
case 4:
|
|
338
|
+
status = "freezing";
|
|
339
|
+
break;
|
|
340
|
+
case 9:
|
|
341
|
+
status = "toBeDeleted";
|
|
342
|
+
break;
|
|
343
|
+
case 10:
|
|
344
|
+
status = "synchronizing";
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
543
347
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
348
|
+
const effectiveConfig = {
|
|
349
|
+
effectiveDate: item.effectiveTime,
|
|
350
|
+
expiredDate: item.invalidTime,
|
|
351
|
+
};
|
|
352
|
+
if (item.scheduleDetails?.length) {
|
|
353
|
+
const scheduleDetail = item.scheduleDetails[0];
|
|
354
|
+
effectiveConfig.repeat =
|
|
355
|
+
scheduleDetail.allDay === false ? "week" : "none";
|
|
356
|
+
if (effectiveConfig.repeat === "week") {
|
|
357
|
+
effectiveConfig.weeks = parseWeek(scheduleDetail.workingDay);
|
|
358
|
+
effectiveConfig.effectiveTime = scheduleDetail.effectiveTime;
|
|
359
|
+
effectiveConfig.expiredTime = scheduleDetail.invalidTime;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const data = {
|
|
363
|
+
unlockBindingId: item.unlockBindingId,
|
|
364
|
+
name: item.name,
|
|
365
|
+
status,
|
|
366
|
+
type,
|
|
367
|
+
sn: item.sn,
|
|
368
|
+
hasClearPwd: item.opModeInfo?.hasClearPwd === true,
|
|
369
|
+
effectiveConfig,
|
|
370
|
+
};
|
|
371
|
+
if (data.type === "clearOne") {
|
|
372
|
+
data.clearInfo = {
|
|
373
|
+
name: item.opModeInfo?.revokedPwdName || "",
|
|
374
|
+
effectiveConfig: {
|
|
375
|
+
effectiveDate: item.opModeInfo?.revokedPwdEffectiveTime || 0,
|
|
376
|
+
expiredDate: item.opModeInfo?.revokedPwdInvalidTime || 0,
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return data;
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
export const getTempInvalidList = async (params) => {
|
|
384
|
+
const res = await fetchInvalidList({
|
|
385
|
+
devId: config.devInfo.devId,
|
|
386
|
+
offset: (params?.page || 1) - 1,
|
|
387
|
+
limit: params?.pageSize || 200,
|
|
388
|
+
});
|
|
389
|
+
const list = res.datas.map((item) => {
|
|
390
|
+
const type = passwordTypeMap[`${item.opModeType}-${item.opModeSubType}`] || "custom";
|
|
391
|
+
let status = "expired";
|
|
392
|
+
let invalidReason = "synchronizationFailed";
|
|
393
|
+
if (item.phase === 8) {
|
|
394
|
+
invalidReason = "deleted";
|
|
395
|
+
}
|
|
396
|
+
if (item.failReason) {
|
|
397
|
+
switch (item.phase) {
|
|
398
|
+
case 1:
|
|
399
|
+
invalidReason = "synchronizationFailed";
|
|
400
|
+
break;
|
|
401
|
+
case 2:
|
|
402
|
+
invalidReason = "passwordFull";
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const effectiveConfig = {
|
|
407
|
+
effectiveDate: item.effectiveTime,
|
|
408
|
+
expiredDate: item.invalidTime,
|
|
409
|
+
};
|
|
410
|
+
if (item.scheduleDetails?.length) {
|
|
411
|
+
const scheduleDetail = item.scheduleDetails[0];
|
|
412
|
+
effectiveConfig.repeat =
|
|
413
|
+
scheduleDetail.allDay === false ? "week" : "none";
|
|
414
|
+
if (effectiveConfig.repeat === "week") {
|
|
415
|
+
effectiveConfig.weeks = parseWeek(scheduleDetail.workingDay);
|
|
416
|
+
effectiveConfig.effectiveTime = scheduleDetail.effectiveTime;
|
|
417
|
+
effectiveConfig.expiredTime = scheduleDetail.invalidTime;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const data = {
|
|
421
|
+
unlockBindingId: item.unlockBindingId,
|
|
422
|
+
name: item.name,
|
|
423
|
+
invalidReason,
|
|
424
|
+
status,
|
|
425
|
+
type,
|
|
426
|
+
sn: item.sn,
|
|
427
|
+
hasClearPwd: item.opModeInfo?.hasClearPwd === true,
|
|
428
|
+
effectiveConfig,
|
|
429
|
+
};
|
|
430
|
+
if (data.type === "clearOne") {
|
|
431
|
+
data.clearInfo = {
|
|
432
|
+
name: item.opModeInfo?.revokedPwdName || "",
|
|
433
|
+
effectiveConfig: {
|
|
434
|
+
effectiveDate: item.opModeInfo?.revokedPwdEffectiveTime || 0,
|
|
435
|
+
expiredDate: item.opModeInfo?.revokedPwdInvalidTime || 0,
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
return data;
|
|
440
|
+
});
|
|
441
|
+
return {
|
|
442
|
+
list,
|
|
443
|
+
hasMore: res.hasNext,
|
|
444
|
+
total: res.totalCount,
|
|
445
|
+
};
|
|
553
446
|
};
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* 清空无效的临时密码列表
|
|
557
|
-
*/
|
|
558
447
|
export const clearTempInvalidList = async () => {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
448
|
+
return clearInvalidTempList({
|
|
449
|
+
devId: config.devInfo.devId,
|
|
450
|
+
});
|
|
562
451
|
};
|
|
563
452
|
const changePasswordPhase = async (unlockBindingId, phase) => {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
});
|
|
568
|
-
const password = list.find(item => item.unlockBindingId === unlockBindingId);
|
|
569
|
-
if (!password) {
|
|
570
|
-
throw getError(1051);
|
|
571
|
-
}
|
|
572
|
-
try {
|
|
573
|
-
await updateTemporaryPassword({
|
|
574
|
-
unlockBindingId: unlockBindingId,
|
|
575
|
-
schedule: password.scheduleDetails,
|
|
576
|
-
effectiveTime: password.effectiveTime,
|
|
577
|
-
invalidTime: password.invalidTime,
|
|
578
|
-
name: password.name,
|
|
579
|
-
phase,
|
|
580
|
-
symbolic: false,
|
|
581
|
-
dpTunnel: 2,
|
|
582
|
-
devId: config.devInfo.devId
|
|
453
|
+
const list = await fetchEffectiveList({
|
|
454
|
+
devId: config.devInfo.devId,
|
|
455
|
+
authTypes: ["LOCK_OFFLINE_TEMP_PWD", "LOCK_TEMP_PWD"],
|
|
583
456
|
});
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
457
|
+
const password = list.find((item) => item.unlockBindingId === unlockBindingId);
|
|
458
|
+
if (!password) {
|
|
459
|
+
throw getError(1051);
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
await updateTemporaryPassword({
|
|
463
|
+
unlockBindingId: unlockBindingId,
|
|
464
|
+
schedule: password.scheduleDetails,
|
|
465
|
+
effectiveTime: password.effectiveTime,
|
|
466
|
+
invalidTime: password.invalidTime,
|
|
467
|
+
name: password.name,
|
|
468
|
+
phase,
|
|
469
|
+
symbolic: false,
|
|
470
|
+
dpTunnel: 2,
|
|
471
|
+
devId: config.devInfo.devId,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
catch (e) {
|
|
475
|
+
handleError(e);
|
|
476
|
+
}
|
|
477
|
+
return true;
|
|
588
478
|
};
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
* 冻结临时密码
|
|
592
|
-
* @param params
|
|
593
|
-
* @returns
|
|
594
|
-
*/
|
|
595
|
-
export const freezeTemp = async params => {
|
|
596
|
-
return changePasswordPhase(params.unlockBindingId, 4);
|
|
479
|
+
export const freezeTemp = async (params) => {
|
|
480
|
+
return changePasswordPhase(params.unlockBindingId, 4);
|
|
597
481
|
};
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
* 解冻临时密码
|
|
601
|
-
* @param params
|
|
602
|
-
* @returns
|
|
603
|
-
*/
|
|
604
|
-
export const unfreezeTemp = async params => {
|
|
605
|
-
return changePasswordPhase(params.unlockBindingId, 2);
|
|
482
|
+
export const unfreezeTemp = async (params) => {
|
|
483
|
+
return changePasswordPhase(params.unlockBindingId, 2);
|
|
606
484
|
};
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
* @param {RenameParams} params
|
|
610
|
-
*/
|
|
611
|
-
export const renameTemp = async params => {
|
|
612
|
-
const list = await fetchEffectiveList({
|
|
613
|
-
devId: config.devInfo.devId,
|
|
614
|
-
authTypes: ["LOCK_OFFLINE_TEMP_PWD", "LOCK_TEMP_PWD"]
|
|
615
|
-
});
|
|
616
|
-
const password = list.find(item => item.unlockBindingId === params.unlockBindingId);
|
|
617
|
-
if (!password) {
|
|
618
|
-
throw getError(1051);
|
|
619
|
-
}
|
|
620
|
-
try {
|
|
621
|
-
if (password.opModeType === 1) {
|
|
622
|
-
await reNameTemporary({
|
|
623
|
-
devId: config.devInfo.devId,
|
|
624
|
-
unlockBindingId: params.unlockBindingId,
|
|
625
|
-
name: params.name
|
|
626
|
-
});
|
|
627
|
-
} else {
|
|
628
|
-
await reNameOffline({
|
|
485
|
+
export const renameTemp = async (params) => {
|
|
486
|
+
const list = await fetchEffectiveList({
|
|
629
487
|
devId: config.devInfo.devId,
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
488
|
+
authTypes: ["LOCK_OFFLINE_TEMP_PWD", "LOCK_TEMP_PWD"],
|
|
489
|
+
});
|
|
490
|
+
const password = list.find((item) => item.unlockBindingId === params.unlockBindingId);
|
|
491
|
+
if (!password) {
|
|
492
|
+
throw getError(1051);
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
if (password.opModeType === 1) {
|
|
496
|
+
await reNameTemporary({
|
|
497
|
+
devId: config.devInfo.devId,
|
|
498
|
+
unlockBindingId: params.unlockBindingId,
|
|
499
|
+
name: params.name,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
await reNameOffline({
|
|
504
|
+
devId: config.devInfo.devId,
|
|
505
|
+
unlockBindingId: params.unlockBindingId,
|
|
506
|
+
pwdName: params.name,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
633
509
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
};
|
|
510
|
+
catch (e) {
|
|
511
|
+
handleError(e);
|
|
512
|
+
}
|
|
513
|
+
};
|