@ray-js/lock-sdk 1.1.0 → 1.1.1-beta.10
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 +8 -0
- package/lib/api/index.js +10 -0
- package/lib/api/lock.d.ts +5 -0
- package/lib/api/lock.js +7 -0
- package/lib/api/temp.js +1 -1
- package/lib/api/user.d.ts +6 -0
- package/lib/api/user.js +9 -2
- package/lib/capability.js +44 -18
- package/lib/config/dp-code/index.d.ts +1 -0
- package/lib/config/dp-code/index.js +1 -0
- package/lib/config/dp-map/common.js +1 -1
- package/lib/config/dp-map/unlock-method-big.d.ts +10 -11
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.js +1 -0
- package/lib/index.js +2 -1
- package/lib/interface.d.ts +14 -1
- package/lib/log.js +16 -4
- package/lib/open.js +22 -12
- package/lib/other.d.ts +1 -0
- package/lib/other.js +18 -10
- package/lib/state.js +65 -73
- package/lib/sync/temp.js +1 -1
- package/lib/sync/user.js +2 -38
- package/lib/temporary.d.ts +2 -1
- package/lib/temporary.js +60 -16
- package/lib/unlock-method.d.ts +3 -1
- package/lib/unlock-method.js +59 -7
- package/lib/user.d.ts +22 -2
- package/lib/user.js +115 -104
- package/lib/utils/device.d.ts +1 -0
- package/lib/utils/device.js +1 -1
- package/lib/utils/errors.js +3 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +16 -13
- package/lib/utils/publishDps.js +1 -1
- package/lib/utils/user.d.ts +2 -0
- package/lib/utils/user.js +39 -0
- package/package.json +1 -1
- package/lib/dp-interface.d.ts +0 -7
- package/lib/dp-interface.js +0 -1
- package/lib/sync/unlock-mothod.d.ts +0 -2
- package/lib/sync/unlock-mothod.js +0 -42
package/lib/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import config, { hasCapability } from "./config";
|
|
1
|
+
import config, { hasCapability, hasDp } from "./config";
|
|
2
2
|
import { onDpDataChange, onDeviceInfoUpdated, offDeviceInfoUpdated, offDpDataChange, registerDevice, getDeviceOnlineType, onOnlineChange, offOnlineChange, onBleChange, offBleChange, registerBleStatus, getDeviceInfo, onMqttMessage, registerMQTTDeviceListener, registerMQTTProtocolListener, offMqttMessage, onAppShow, onAppHide, } from "./utils/device";
|
|
3
3
|
import { getDeviceProperties } from "./api/setting";
|
|
4
4
|
import { parseCapabilities } from "./parse";
|
|
@@ -38,87 +38,75 @@ const updateOnlineType = async () => {
|
|
|
38
38
|
updateDeviceStatus();
|
|
39
39
|
};
|
|
40
40
|
export const getDeviceStatus = () => {
|
|
41
|
-
const { onlineType,
|
|
41
|
+
const { onlineType, devInfo: { isCloudOnline, isOnline, wifiEnableState }, } = config;
|
|
42
42
|
const status = {
|
|
43
43
|
type: isOnline ? "online" : "offline",
|
|
44
44
|
connectEnable: false,
|
|
45
45
|
onlineType: "unknown",
|
|
46
|
+
onlineTypes: [],
|
|
46
47
|
isWifiActive: wifiEnableState !== 1,
|
|
47
48
|
};
|
|
48
|
-
const isBleOnline =
|
|
49
|
+
const isBleOnline = isOnlineByType(onlineType, 2);
|
|
49
50
|
const isLocalOnline = !isCloudOnline && isOnlineByType(onlineType, 1);
|
|
50
51
|
const supportWifi = hasCapability(ProductCommunicationType.WIFI);
|
|
51
52
|
const supportBle = hasCapability(ProductCommunicationType.BLUETOOTH);
|
|
52
53
|
const supportThread = hasCapability(ProductCommunicationType.THREAD);
|
|
53
|
-
const hasWirelessAwakeDp =
|
|
54
|
+
const hasWirelessAwakeDp = hasDp(dpCodes.wirelessAwake);
|
|
54
55
|
const wirelessAwake = getDpValue(dpCodes.wirelessAwake);
|
|
55
|
-
const isDeviceOnline = hasWirelessAwakeDp
|
|
56
|
-
? wirelessAwake && isCloudOnline
|
|
57
|
-
: isCloudOnline;
|
|
58
56
|
status.connectEnable = isSupportBleControl() && !isOnline;
|
|
59
57
|
if (supportWifi) {
|
|
60
58
|
if (!status.connectEnable) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
switch (communication.length) {
|
|
66
|
-
case 1: {
|
|
67
|
-
if (supportWifi) {
|
|
68
|
-
if (isDeviceOnline) {
|
|
69
|
-
status.type = "online";
|
|
70
|
-
status.onlineType = "cloud";
|
|
71
|
-
}
|
|
72
|
-
if (isSleep()) {
|
|
73
|
-
status.type = "sleep";
|
|
74
|
-
}
|
|
59
|
+
if (isCloudOnline) {
|
|
60
|
+
status.connectEnable =
|
|
61
|
+
hasWirelessAwakeDp && wirelessAwake === false && !isBleOnline;
|
|
75
62
|
}
|
|
76
|
-
else if (supportBle) {
|
|
77
|
-
status.connectEnable = true;
|
|
78
|
-
if (isOnline) {
|
|
79
|
-
status.type = "online";
|
|
80
|
-
status.onlineType = "ble";
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
63
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
status.type = "online";
|
|
96
|
-
status.onlineType = "cloud";
|
|
97
|
-
}
|
|
98
|
-
if (isSleep()) {
|
|
99
|
-
status.type = "sleep";
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
if (supportThread && supportBle) {
|
|
104
|
-
const isShareThread = isShareThead();
|
|
105
|
-
if (isLocalOnline || (isShareThread && isOnline)) {
|
|
106
|
-
status.type = "online";
|
|
107
|
-
status.onlineType = "local";
|
|
108
|
-
}
|
|
109
|
-
else if (isCloudOnline) {
|
|
110
|
-
status.type = "online";
|
|
111
|
-
status.onlineType = "cloud";
|
|
112
|
-
}
|
|
113
|
-
else if (isBleOnline) {
|
|
114
|
-
status.type = "online";
|
|
115
|
-
status.onlineType = "ble";
|
|
64
|
+
}
|
|
65
|
+
if (isOnline) {
|
|
66
|
+
if (isCloudOnline) {
|
|
67
|
+
if (hasWirelessAwakeDp) {
|
|
68
|
+
if (wirelessAwake) {
|
|
69
|
+
status.onlineTypes.push("cloud");
|
|
116
70
|
}
|
|
117
71
|
else {
|
|
118
72
|
status.type = "offline";
|
|
119
73
|
}
|
|
120
74
|
}
|
|
121
|
-
|
|
75
|
+
else {
|
|
76
|
+
status.onlineTypes.push("cloud");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (isLocalOnline) {
|
|
80
|
+
status.onlineTypes.push("local");
|
|
81
|
+
}
|
|
82
|
+
if (isBleOnline) {
|
|
83
|
+
status.onlineTypes.push("ble");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (status.onlineTypes.length === 0 && isOnline) {
|
|
87
|
+
status.onlineTypes.push("unknown");
|
|
88
|
+
}
|
|
89
|
+
if (supportThread && supportBle) {
|
|
90
|
+
const isShareThread = isShareThead();
|
|
91
|
+
if (isShareThread && isOnline) {
|
|
92
|
+
status.onlineTypes = ["local"];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (status.onlineTypes.includes("ble")) {
|
|
96
|
+
status.onlineType = "ble";
|
|
97
|
+
}
|
|
98
|
+
else if (status.onlineTypes.includes("cloud")) {
|
|
99
|
+
status.onlineType = "cloud";
|
|
100
|
+
}
|
|
101
|
+
else if (status.onlineTypes.includes("local")) {
|
|
102
|
+
status.onlineType = "local";
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
status.onlineType = "unknown";
|
|
106
|
+
}
|
|
107
|
+
if (!isOnline) {
|
|
108
|
+
if (isSleep()) {
|
|
109
|
+
status.type = "sleep";
|
|
122
110
|
}
|
|
123
111
|
}
|
|
124
112
|
if (status.type === "sleep") {
|
|
@@ -211,24 +199,29 @@ export const permissions = [
|
|
|
211
199
|
"everyOne",
|
|
212
200
|
"noOne",
|
|
213
201
|
];
|
|
202
|
+
var DeviceProperties;
|
|
203
|
+
(function (DeviceProperties) {
|
|
204
|
+
DeviceProperties["REMOTE_UNLOCK_AUTH"] = "REMOTE_UNLOCK_AUTH";
|
|
205
|
+
DeviceProperties["UNLOCK_PHONE_REMOTE"] = "UNLOCK_PHONE_REMOTE";
|
|
206
|
+
})(DeviceProperties || (DeviceProperties = {}));
|
|
207
|
+
const propsList = [
|
|
208
|
+
DeviceProperties.REMOTE_UNLOCK_AUTH,
|
|
209
|
+
DeviceProperties.UNLOCK_PHONE_REMOTE,
|
|
210
|
+
];
|
|
214
211
|
const fetchDeviceProperties = async (isForce) => {
|
|
215
212
|
let result = null;
|
|
216
213
|
if (isForce) {
|
|
217
|
-
result = await getDeviceProperties(config.devInfo.devId,
|
|
218
|
-
"REMOTE_UNLOCK_AUTH",
|
|
219
|
-
"UNLOCK_PHONE_REMOTE",
|
|
220
|
-
]);
|
|
214
|
+
result = await getDeviceProperties(config.devInfo.devId, propsList);
|
|
221
215
|
}
|
|
222
216
|
else {
|
|
223
217
|
result = await getDataWithPreFetch("getDeviceProperties", () => {
|
|
224
|
-
return getDeviceProperties(config.devInfo.devId,
|
|
225
|
-
"REMOTE_UNLOCK_AUTH",
|
|
226
|
-
"UNLOCK_PHONE_REMOTE",
|
|
227
|
-
]);
|
|
218
|
+
return getDeviceProperties(config.devInfo.devId, propsList);
|
|
228
219
|
});
|
|
229
220
|
}
|
|
230
|
-
config.remoteOpenEnabled =
|
|
231
|
-
|
|
221
|
+
config.remoteOpenEnabled =
|
|
222
|
+
result[DeviceProperties.UNLOCK_PHONE_REMOTE] === "true";
|
|
223
|
+
config.remoteOpenPermission =
|
|
224
|
+
permissions[+result[DeviceProperties.REMOTE_UNLOCK_AUTH] || 0];
|
|
232
225
|
};
|
|
233
226
|
export const initState = async () => {
|
|
234
227
|
const { devInfo: { dps, devId }, dpSchema, } = config;
|
|
@@ -247,8 +240,7 @@ export const initState = async () => {
|
|
|
247
240
|
]);
|
|
248
241
|
config.imageAngle = rotateInfo.angle;
|
|
249
242
|
config.videoAngle = rotateInfo.actualAngle;
|
|
250
|
-
fetchDeviceProperties()
|
|
251
|
-
});
|
|
243
|
+
fetchDeviceProperties();
|
|
252
244
|
getDeviceAdvancedAbilities();
|
|
253
245
|
syncRemoteSerectKey();
|
|
254
246
|
setTimeout(() => {
|
package/lib/sync/temp.js
CHANGED
package/lib/sync/user.js
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
1
|
import { getDeviceStatus } from "../state";
|
|
2
2
|
import { ProductCommunicationType } from "../constant";
|
|
3
3
|
import config, { hasCapability } from "../config";
|
|
4
|
-
import { getUsersSyncLockData
|
|
5
|
-
import
|
|
6
|
-
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
7
|
-
import { remove as removeBigMap, reportRemove as reportRemoveBigMap, } from "../config/dp-map/unlock-method-big";
|
|
8
|
-
import { remove as removeMap, reportRemove as reportRemoveMap, } from "../config/dp-map/unlock-method";
|
|
9
|
-
import { publishDps } from "../utils/publishDps";
|
|
10
|
-
const deleteUser = async (data) => {
|
|
11
|
-
const { admin, lockUserId, userId } = data;
|
|
12
|
-
const dpCode = config.supportBigData
|
|
13
|
-
? dpCodes.unlockMethodDelW
|
|
14
|
-
: dpCodes.unlockMethodDel;
|
|
15
|
-
const dpData = {
|
|
16
|
-
type: 0,
|
|
17
|
-
stage: 0,
|
|
18
|
-
admin: !!admin,
|
|
19
|
-
memberId: lockUserId,
|
|
20
|
-
unlockId: config.supportBigData ? 0xffff : 0xff,
|
|
21
|
-
category: 0,
|
|
22
|
-
};
|
|
23
|
-
await publishDps({
|
|
24
|
-
[dpCode]: dpUtils.format(dpData, (config.supportBigData ? removeBigMap : removeMap)),
|
|
25
|
-
}, {
|
|
26
|
-
checkReport: (dps) => {
|
|
27
|
-
if (dps[dpCode]) {
|
|
28
|
-
const dpValue = dpUtils.parse(dps[dpCode], (config.supportBigData
|
|
29
|
-
? reportRemoveBigMap
|
|
30
|
-
: reportRemoveMap));
|
|
31
|
-
if (dpValue.type === 0 &&
|
|
32
|
-
dpValue.status == 255 &&
|
|
33
|
-
dpValue.memberId === lockUserId) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
await removeUser(config.devInfo.devId, userId);
|
|
41
|
-
};
|
|
4
|
+
import { getUsersSyncLockData } from "../api/user";
|
|
5
|
+
import { deleteUser } from "../utils/user";
|
|
42
6
|
let isSyncDone = false;
|
|
43
7
|
const syncDeleteUsers = async () => {
|
|
44
8
|
const deviceStatus = getDeviceStatus();
|
package/lib/temporary.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ interface CreateCustomParams {
|
|
|
7
7
|
export declare const createTempCustom: (params: CreateCustomParams) => Promise<TempPasswordResult>;
|
|
8
8
|
interface RemoveCustomProps {
|
|
9
9
|
unlockBindingId: string;
|
|
10
|
+
sn: number;
|
|
10
11
|
}
|
|
11
|
-
export declare const removeTempCustom: (params: RemoveCustomProps) => Promise<
|
|
12
|
+
export declare const removeTempCustom: (params: RemoveCustomProps) => Promise<true | undefined>;
|
|
12
13
|
interface UpdateTempPasswordParams {
|
|
13
14
|
unlockBindingId: string;
|
|
14
15
|
name: string;
|
package/lib/temporary.js
CHANGED
|
@@ -4,25 +4,41 @@ import { formatWeek, isUseNearChannel, parallelOnly, parseOfflinePassword, parse
|
|
|
4
4
|
import { LoopTypes } from "./utils/constant";
|
|
5
5
|
import { encrypt } from "./utils/device";
|
|
6
6
|
import { getError } from "./utils/errors";
|
|
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";
|
|
7
|
+
import { addTempPwd as addTempPwdDpMap, reportAddTempPwd as reportAddTempPwdDpMap, removeTempPwd as removeTempPwdDpMap, reportRemoveTempPwd as reportRemoveTempPwdDpMap, } from "./config/dp-map/unlock-method";
|
|
8
|
+
import { addTempPwd as addTempPwdBigDpMap, reportAddTempPwd as reportAddTempPwdDBigpMap, removeTempPwd as removeTempPwdBigDpMap, reportRemoveTempPwd as reportRemoveTempPwdBigDpMap, } from "./config/dp-map/unlock-method-big";
|
|
9
9
|
import { publishDps } from "./utils/publishDps";
|
|
10
10
|
import dpCodes from "./config/dp-code";
|
|
11
11
|
import dpUtils from "@ray-js/tuya-dp-transform";
|
|
12
12
|
const PASSWORD_REGEX = /^[0-9]+$/;
|
|
13
|
-
const handleError = (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const handleError = (err) => {
|
|
14
|
+
if (err?.innerError?.errorCode) {
|
|
15
|
+
let error;
|
|
16
|
+
switch (err.innerError.errorCode) {
|
|
17
|
+
case "USER_PWD_ALREADY_EXIST":
|
|
18
|
+
error = getError(1037);
|
|
19
|
+
break;
|
|
20
|
+
case "LOCK_PWD_NAME_REPEAT":
|
|
21
|
+
case "OFFLINE_PWD_NAME_REPEAT":
|
|
22
|
+
error = getError(1038);
|
|
23
|
+
break;
|
|
24
|
+
case "START_END_DATE_NOT_RIGHT":
|
|
25
|
+
error = getError(1039);
|
|
26
|
+
break;
|
|
27
|
+
case "RECORD_NOT_EXIST":
|
|
28
|
+
error = getError(1040);
|
|
29
|
+
break;
|
|
30
|
+
case "OFFLINE_PWD_EXAUST_IN_PERIOD":
|
|
31
|
+
error = getError(1067);
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
}
|
|
35
|
+
if (error) {
|
|
36
|
+
error.errorMsg = err.innerError.errorMsg;
|
|
37
|
+
error.innerError = err.innerError;
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
25
40
|
}
|
|
41
|
+
throw err;
|
|
26
42
|
};
|
|
27
43
|
const isValidPassword = async (params) => {
|
|
28
44
|
const validateResult = await validateTempPwd(params);
|
|
@@ -83,7 +99,7 @@ export const createTempCustom = parallelOnly(async (params) => {
|
|
|
83
99
|
endTime: effective.expiredDate,
|
|
84
100
|
loop: loopType,
|
|
85
101
|
loopConfig: 0,
|
|
86
|
-
weeks: effective.weeks
|
|
102
|
+
weeks: effective.weeks ? effective.weeks : [0, 0, 0, 0, 0, 0, 0],
|
|
87
103
|
days: [],
|
|
88
104
|
startHour: Math.floor(effectiveTime / 60),
|
|
89
105
|
startMinute: effectiveTime % 60,
|
|
@@ -150,12 +166,40 @@ export const createTempCustom = parallelOnly(async (params) => {
|
|
|
150
166
|
});
|
|
151
167
|
export const removeTempCustom = async (params) => {
|
|
152
168
|
try {
|
|
153
|
-
|
|
169
|
+
await deleteTempPassword({
|
|
154
170
|
devId: config.devInfo.devId,
|
|
155
171
|
unlockBindingId: params.unlockBindingId,
|
|
156
172
|
symbolic: false,
|
|
157
173
|
dpTunnel: 2,
|
|
158
174
|
});
|
|
175
|
+
if (isUseNearChannel()) {
|
|
176
|
+
const dpCode = config.supportBigData
|
|
177
|
+
? dpCodes.tempPwdDelW
|
|
178
|
+
: dpCodes.tempPwdDel;
|
|
179
|
+
const dpData = {
|
|
180
|
+
unlockId: params.sn,
|
|
181
|
+
};
|
|
182
|
+
const result = await publishDps({
|
|
183
|
+
[dpCode]: dpUtils.format(dpData, (config.supportBigData
|
|
184
|
+
? removeTempPwdBigDpMap
|
|
185
|
+
: removeTempPwdDpMap)),
|
|
186
|
+
}, {
|
|
187
|
+
checkReport: (dpData) => {
|
|
188
|
+
const reportData = dpData[dpCode];
|
|
189
|
+
if (reportData) {
|
|
190
|
+
const data = dpUtils.parse(reportData, (config.supportBigData
|
|
191
|
+
? reportRemoveTempPwdBigDpMap
|
|
192
|
+
: reportRemoveTempPwdDpMap));
|
|
193
|
+
return data;
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
if (result.status === 0) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
throw getError(1065);
|
|
202
|
+
}
|
|
159
203
|
}
|
|
160
204
|
catch (e) {
|
|
161
205
|
handleError(e);
|
package/lib/unlock-method.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ErrorData, UnBindUnlockMethodGroup, UnlockMethodDetail, UnlockMethodType } from "./interface";
|
|
1
|
+
import { ErrorData, UnBindUnlockMethodGroup, UnlockGuide, UnlockMethodDetail, UnlockMethodType } from "./interface";
|
|
2
2
|
export interface SpecialUnlockMethodInfo {
|
|
3
3
|
appSend?: boolean;
|
|
4
|
+
msgSend?: boolean;
|
|
4
5
|
msgPhone?: string;
|
|
5
6
|
verifyCode?: string;
|
|
6
7
|
countryCode?: string;
|
|
@@ -85,4 +86,5 @@ export type AddUnlockMethodEvent = StepEvent | SuccessEvent | ErrorEvent;
|
|
|
85
86
|
export type AddUnlockMethodListener = (event: AddUnlockMethodEvent) => void;
|
|
86
87
|
export declare const onAddUnlockMethod: (listener: AddUnlockMethodListener) => void;
|
|
87
88
|
export declare const offAddUnlockMethod: (listener: AddUnlockMethodListener) => void;
|
|
89
|
+
export declare const getUnlockGuide: (type: UnlockMethodType) => Promise<UnlockGuide | null>;
|
|
88
90
|
export {};
|
package/lib/unlock-method.js
CHANGED
|
@@ -12,8 +12,9 @@ import { publishDps } from "./utils/publishDps";
|
|
|
12
12
|
import { encrypt } from "./utils/device";
|
|
13
13
|
import emitter from "./utils/event";
|
|
14
14
|
import { DPCHANGE, UNLOCK_METHOD_EVENT } from "./utils/constant";
|
|
15
|
-
import { sendPhoneVerifyCode } from "./api";
|
|
15
|
+
import { getFileRemoteUrl, sendPhoneVerifyCode } from "./api";
|
|
16
16
|
import { getUserInfo } from "./user";
|
|
17
|
+
import { getDeviceAdvancedAbilities } from "./capability";
|
|
17
18
|
const getAddUnlockError = (status) => {
|
|
18
19
|
if (status >= 0 && status <= 10) {
|
|
19
20
|
return getError(1015 + status);
|
|
@@ -30,6 +31,7 @@ export const getUnlockMethodDetail = async (id) => {
|
|
|
30
31
|
});
|
|
31
32
|
const detail = {
|
|
32
33
|
isBound: cloudData.allocateFlag === 1,
|
|
34
|
+
type: getUnlockMethodTypeByDpCode(config.codesById[Number(cloudData.opmode)])?.type,
|
|
33
35
|
phase: cloudData.phase,
|
|
34
36
|
dpId: Number(cloudData.opmode),
|
|
35
37
|
isSpecial: cloudData.unlockAttr === 1,
|
|
@@ -41,6 +43,7 @@ export const getUnlockMethodDetail = async (id) => {
|
|
|
41
43
|
userType: cloudData.userType,
|
|
42
44
|
notifyInfo: {
|
|
43
45
|
appSend: !!cloudData.notifyInfo?.appSend,
|
|
46
|
+
msgSend: !!cloudData.notifyInfo?.msgPhone,
|
|
44
47
|
msgPhone: cloudData.notifyInfo?.msgPhone,
|
|
45
48
|
countryCode: cloudData.notifyInfo?.countryCode,
|
|
46
49
|
},
|
|
@@ -48,7 +51,7 @@ export const getUnlockMethodDetail = async (id) => {
|
|
|
48
51
|
return detail;
|
|
49
52
|
};
|
|
50
53
|
const getUnlockMethodBase = async (type, userId) => {
|
|
51
|
-
const { idsByCode, devInfo: { devId }, supportBigData,
|
|
54
|
+
const { idsByCode, devInfo: { devId }, supportBigData, } = config;
|
|
52
55
|
const unlockMethodConfig = getUnlockMethodTypeByType(type);
|
|
53
56
|
const addDpCode = supportBigData
|
|
54
57
|
? dpCodes.unlockMethodCreateW
|
|
@@ -104,11 +107,14 @@ const checkSpecial = (isSpecial, params, oldSetting) => {
|
|
|
104
107
|
if (!supportedPhone) {
|
|
105
108
|
throw getError(1057);
|
|
106
109
|
}
|
|
107
|
-
else if (!params?.
|
|
110
|
+
else if (!params?.msgSend) {
|
|
108
111
|
throw getError(1058);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
if (supportedPhone && params?.
|
|
114
|
+
if (supportedPhone && params?.msgSend) {
|
|
115
|
+
if (!params.msgPhone) {
|
|
116
|
+
throw getError(1066);
|
|
117
|
+
}
|
|
112
118
|
if (!params.countryCode) {
|
|
113
119
|
throw getError(1056);
|
|
114
120
|
}
|
|
@@ -121,9 +127,9 @@ const checkSpecial = (isSpecial, params, oldSetting) => {
|
|
|
121
127
|
unlockAttr: isSpecial ? 1 : 0,
|
|
122
128
|
notifyInfo: {
|
|
123
129
|
appSend: !!params?.appSend,
|
|
124
|
-
msgPhone: supportedPhone ? params?.msgPhone : undefined,
|
|
125
|
-
countryCode: supportedPhone ? params?.countryCode : undefined,
|
|
126
|
-
msgPhoneVerifyCode: supportedPhone ? params?.verifyCode : undefined,
|
|
130
|
+
msgPhone: supportedPhone && params?.msgSend ? params?.msgPhone : undefined,
|
|
131
|
+
countryCode: supportedPhone && params?.msgSend ? params?.countryCode : undefined,
|
|
132
|
+
msgPhoneVerifyCode: supportedPhone && params?.msgSend ? params?.verifyCode : undefined,
|
|
127
133
|
},
|
|
128
134
|
};
|
|
129
135
|
};
|
|
@@ -560,3 +566,49 @@ export const onAddUnlockMethod = (listener) => {
|
|
|
560
566
|
export const offAddUnlockMethod = (listener) => {
|
|
561
567
|
emitter.off(UNLOCK_METHOD_EVENT, listener);
|
|
562
568
|
};
|
|
569
|
+
const guileTypeMap = {
|
|
570
|
+
card: ["addCard", "addCardPic"],
|
|
571
|
+
finger: ["addFingerprint", "addFingerprintPic"],
|
|
572
|
+
face: ["addFace", "addFacePic"],
|
|
573
|
+
fingerVein: ["addFingervein", "addFingerveinPic"],
|
|
574
|
+
hand: ["addPalmvein", "addPalmveinPic"],
|
|
575
|
+
eye: ["addIris", "addIrisPic"],
|
|
576
|
+
};
|
|
577
|
+
export const getUnlockGuide = async (type) => {
|
|
578
|
+
if (type === "password") {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
const { unlockGuide } = await getDeviceAdvancedAbilities();
|
|
582
|
+
if (unlockGuide.support) {
|
|
583
|
+
const [videoKey, picKey] = guileTypeMap[type] || ["", ""];
|
|
584
|
+
const resources = [];
|
|
585
|
+
let videoUrlPath = "";
|
|
586
|
+
let picUrlPath = "";
|
|
587
|
+
if (unlockGuide.config[picKey]) {
|
|
588
|
+
picUrlPath = unlockGuide.config[picKey].url;
|
|
589
|
+
resources.push({
|
|
590
|
+
objectKey: picUrlPath,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
if (unlockGuide.config[videoKey]) {
|
|
594
|
+
videoUrlPath = unlockGuide.config[videoKey].url;
|
|
595
|
+
resources.push({
|
|
596
|
+
objectKey: videoUrlPath,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
if (resources.length === 0) {
|
|
600
|
+
return null;
|
|
601
|
+
}
|
|
602
|
+
const { signedUrls } = await getFileRemoteUrl({
|
|
603
|
+
biz: "hulk_video_tutorial_video",
|
|
604
|
+
resources,
|
|
605
|
+
});
|
|
606
|
+
const expireTime = Date.now() + 30 * 60 * 1000;
|
|
607
|
+
return {
|
|
608
|
+
videoUrl: signedUrls[videoUrlPath],
|
|
609
|
+
picUrl: signedUrls[picUrlPath],
|
|
610
|
+
expireTime,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
return null;
|
|
614
|
+
};
|
package/lib/user.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EffectiveConfig, UserInfo } from "./interface";
|
|
1
|
+
import { EffectiveConfig, UnlockMethodBaseInfo, UserInfo } from "./interface";
|
|
2
2
|
interface getUsersParams {
|
|
3
3
|
page?: number;
|
|
4
4
|
pageSize?: number;
|
|
@@ -11,7 +11,27 @@ export declare const getUsers: (params?: getUsersParams) => Promise<{
|
|
|
11
11
|
interface getUserInfoParams {
|
|
12
12
|
userId: string;
|
|
13
13
|
}
|
|
14
|
-
export declare const getUserInfo: (params: getUserInfoParams) => Promise<
|
|
14
|
+
export declare const getUserInfo: (params: getUserInfoParams) => Promise<{
|
|
15
|
+
timeScheduleInfo: any;
|
|
16
|
+
unlockDetails: {
|
|
17
|
+
count: number;
|
|
18
|
+
dpCode: string;
|
|
19
|
+
dpId: number;
|
|
20
|
+
type: import("./interface").UnlockMethodType;
|
|
21
|
+
unlockList: UnlockMethodBaseInfo[];
|
|
22
|
+
}[];
|
|
23
|
+
isAccountUser: boolean;
|
|
24
|
+
userId: string;
|
|
25
|
+
lockUserId: number;
|
|
26
|
+
avatarUrl: string;
|
|
27
|
+
backHomeNotifyAttr: number;
|
|
28
|
+
effectiveFlag: number;
|
|
29
|
+
nickName: string;
|
|
30
|
+
offlineUnlock: boolean;
|
|
31
|
+
userContact: string;
|
|
32
|
+
userType: 10 | 20 | 30 | 40 | 50;
|
|
33
|
+
userListType: "panel_user" | "group_user";
|
|
34
|
+
}>;
|
|
15
35
|
interface updateUserLimitTimeParams {
|
|
16
36
|
userId: string;
|
|
17
37
|
lockUserId: number;
|