@ray-js/lock-sdk 1.1.1-beta.1 → 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/user.d.ts +6 -0
- package/lib/api/user.js +9 -2
- package/lib/capability.js +44 -18
- package/lib/config/dp-map/common.js +1 -1
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.js +1 -0
- package/lib/index.js +1 -0
- package/lib/interface.d.ts +13 -1
- package/lib/log.js +16 -4
- package/lib/open.js +10 -10
- package/lib/other.d.ts +1 -0
- package/lib/other.js +9 -1
- package/lib/state.js +35 -21
- package/lib/sync/temp.js +1 -1
- package/lib/temporary.js +39 -23
- 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 +85 -85
- package/lib/utils/errors.js +2 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +15 -12
- package/package.json +1 -1
package/lib/api/index.d.ts
CHANGED
|
@@ -27,4 +27,12 @@ export declare const fetchOfflineDpData: (deviceId: string) => Promise<{
|
|
|
27
27
|
}[]>;
|
|
28
28
|
export declare const publishOfflineDpData: (deviceId: string, dpData: Record<string, DpValue>) => Promise<unknown>;
|
|
29
29
|
export declare const clearOfflineDpData: (deviceId: string) => Promise<unknown>;
|
|
30
|
+
export declare const getFileRemoteUrl: ({ biz, resources, }: {
|
|
31
|
+
biz: string;
|
|
32
|
+
resources: {
|
|
33
|
+
objectKey: string;
|
|
34
|
+
}[];
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
signedUrls: Record<string, string>;
|
|
37
|
+
}>;
|
|
30
38
|
export {};
|
package/lib/api/index.js
CHANGED
|
@@ -70,3 +70,13 @@ export const clearOfflineDpData = async (deviceId) => {
|
|
|
70
70
|
version: "1.0",
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
|
+
export const getFileRemoteUrl = ({ biz, resources, }) => {
|
|
74
|
+
return requestApi({
|
|
75
|
+
api: `${THING}.web.fastroute.download.sign`,
|
|
76
|
+
version: "2.0",
|
|
77
|
+
data: {
|
|
78
|
+
biz,
|
|
79
|
+
signedRequest: { resources },
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
package/lib/api/lock.d.ts
CHANGED
|
@@ -124,4 +124,9 @@ interface BindUnlockMethodToUserByRecordParams {
|
|
|
124
124
|
unlockIds: string[];
|
|
125
125
|
}
|
|
126
126
|
export declare const bindUnlockMethodToUserByRecord: (params: BindUnlockMethodToUserByRecordParams) => Promise<boolean>;
|
|
127
|
+
interface ValidatePasswordComplexityParams {
|
|
128
|
+
devId: string;
|
|
129
|
+
password: string;
|
|
130
|
+
}
|
|
131
|
+
export declare const validatePasswordComplexity: (params: ValidatePasswordComplexityParams) => Promise<boolean>;
|
|
127
132
|
export {};
|
package/lib/api/lock.js
CHANGED
|
@@ -116,3 +116,10 @@ export const bindUnlockMethodToUserByRecord = (params) => {
|
|
|
116
116
|
data: params,
|
|
117
117
|
});
|
|
118
118
|
};
|
|
119
|
+
export const validatePasswordComplexity = (params) => {
|
|
120
|
+
return requestApi({
|
|
121
|
+
api: "m.lock.password.simplicity.check",
|
|
122
|
+
version: "1.0",
|
|
123
|
+
data: params,
|
|
124
|
+
});
|
|
125
|
+
};
|
package/lib/api/user.d.ts
CHANGED
|
@@ -102,6 +102,12 @@ interface UserDetail {
|
|
|
102
102
|
userType: number;
|
|
103
103
|
}
|
|
104
104
|
export declare const getUserDetail: (params: GetUserDetailParams) => Promise<UserDetail>;
|
|
105
|
+
interface GetUserDetailQueryParams {
|
|
106
|
+
devId: string;
|
|
107
|
+
userId: string;
|
|
108
|
+
dpIds: string;
|
|
109
|
+
}
|
|
110
|
+
export declare const getUserDetailQuery: (params: GetUserDetailQueryParams) => Promise<UserListItem>;
|
|
105
111
|
export interface RemovedUserData {
|
|
106
112
|
userId: string;
|
|
107
113
|
lockUserId: number;
|
package/lib/api/user.js
CHANGED
|
@@ -40,8 +40,15 @@ export const getUserList = (params) => {
|
|
|
40
40
|
};
|
|
41
41
|
export const getUserDetail = (params) => {
|
|
42
42
|
return requestApi({
|
|
43
|
-
api:
|
|
44
|
-
version: "
|
|
43
|
+
api: "m.lock.device.member.detail",
|
|
44
|
+
version: "1.0",
|
|
45
|
+
data: params,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export const getUserDetailQuery = (params) => {
|
|
49
|
+
return requestApi({
|
|
50
|
+
api: "m.lock.user.detail.query",
|
|
51
|
+
version: "1.0",
|
|
45
52
|
data: params,
|
|
46
53
|
});
|
|
47
54
|
};
|
package/lib/capability.js
CHANGED
|
@@ -45,6 +45,7 @@ export const getDeviceAdvancedAbilities = async () => {
|
|
|
45
45
|
"tyabi4ucx5",
|
|
46
46
|
"tyabis9tpe",
|
|
47
47
|
"tyabiwxrn9",
|
|
48
|
+
"tyabipd4hh",
|
|
48
49
|
]),
|
|
49
50
|
getDeviceAdvancedAbility(config.devInfo.devId),
|
|
50
51
|
]);
|
|
@@ -68,27 +69,52 @@ export const getDeviceAdvancedAbilities = async () => {
|
|
|
68
69
|
support: false,
|
|
69
70
|
config: {},
|
|
70
71
|
},
|
|
72
|
+
unlockGuide: {
|
|
73
|
+
support: false,
|
|
74
|
+
config: {},
|
|
75
|
+
},
|
|
71
76
|
};
|
|
72
77
|
productAbilities.forEach((item) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
try {
|
|
79
|
+
if (item.isOpen) {
|
|
80
|
+
const data = JSON.parse(item.extConfig);
|
|
81
|
+
switch (item.abilityCode) {
|
|
82
|
+
case "tyabi4ucx5": {
|
|
83
|
+
deviceAdvanceAbilityCache.ai.config = data;
|
|
84
|
+
const dataReport = data?.ai_data_report ?? false;
|
|
85
|
+
const itemRecognition = data?.ai_recognition?.[0]?.item_recognition ?? false;
|
|
86
|
+
const petRecognition = data?.ai_recognition?.[0]?.pet_recognition ?? false;
|
|
87
|
+
const voice = data?.ai_voice ?? false;
|
|
88
|
+
const message = data?.ai_message ?? false;
|
|
89
|
+
deviceAdvanceAbilityCache.ai.support =
|
|
90
|
+
dataReport ||
|
|
91
|
+
itemRecognition ||
|
|
92
|
+
petRecognition ||
|
|
93
|
+
voice ||
|
|
94
|
+
message;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case "tyabis9tpe": {
|
|
98
|
+
deviceAdvanceAbilityCache.wechat.support = true;
|
|
99
|
+
deviceAdvanceAbilityCache.wechat.config = data;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case "tyabiwxrn9": {
|
|
103
|
+
deviceAdvanceAbilityCache.wechatVoip.support =
|
|
104
|
+
!!data?.voipType?.includes("0");
|
|
105
|
+
deviceAdvanceAbilityCache.wechatVoip.config = data;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "tyabipd4hh": {
|
|
109
|
+
deviceAdvanceAbilityCache.unlockGuide.support = true;
|
|
110
|
+
deviceAdvanceAbilityCache.unlockGuide.config = data;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
87
115
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
!!data?.voipType?.includes("0");
|
|
91
|
-
deviceAdvanceAbilityCache.wechatVoip.config = data;
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.warn(`setting [${item.abilityCode}] config error`, error);
|
|
92
118
|
}
|
|
93
119
|
});
|
|
94
120
|
return deviceAdvanceAbilityCache;
|
|
@@ -52,7 +52,7 @@ export const validConfigDpMap = {
|
|
|
52
52
|
.slice(0, 7);
|
|
53
53
|
},
|
|
54
54
|
format: (value) => {
|
|
55
|
-
const weekHex = parseInt(value.reverse().join(""), 2)
|
|
55
|
+
const weekHex = parseInt([...value].reverse().join(""), 2)
|
|
56
56
|
.toString(16)
|
|
57
57
|
.padStart(2, "0");
|
|
58
58
|
return `000000${weekHex}`;
|
package/lib/config/index.d.ts
CHANGED
|
@@ -18,9 +18,10 @@ declare const config: {
|
|
|
18
18
|
videoAngle: number;
|
|
19
19
|
supportMultipleFace: boolean;
|
|
20
20
|
supportOfflineDps: boolean;
|
|
21
|
+
preFetch: boolean;
|
|
21
22
|
deviceStatus: DeviceStatus;
|
|
22
23
|
};
|
|
23
|
-
type UpdateConfigParams = Omit<LockSDKOption, "devInfo" | "deviceId">;
|
|
24
|
+
type UpdateConfigParams = Omit<LockSDKOption, "devInfo" | "deviceId" | "preFetch">;
|
|
24
25
|
export declare const updateConfig: (options: UpdateConfigParams) => void;
|
|
25
26
|
export declare const hasCapability: (capability: ProductCommunicationType) => boolean;
|
|
26
27
|
export declare const hasDp: (dpCode: string) => boolean;
|
package/lib/config/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -60,6 +60,7 @@ export const init = async (options) => {
|
|
|
60
60
|
config.codesById = codesById;
|
|
61
61
|
config.idsByCode = idsByCode;
|
|
62
62
|
config.supportBigData = !!dpSchema[dpCodes.synchMethodW];
|
|
63
|
+
config.preFetch = options?.preFetch ?? false;
|
|
63
64
|
config.communication = getCapabilities(devInfo.capability).map((item) => item.id);
|
|
64
65
|
addEvents();
|
|
65
66
|
await initState();
|
package/lib/interface.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface LockSDKOption {
|
|
|
10
10
|
passwordSupportZero?: boolean;
|
|
11
11
|
supportMultipleFace?: boolean;
|
|
12
12
|
supportOfflineDps?: boolean;
|
|
13
|
+
preFetch?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export interface ErrorData {
|
|
15
16
|
errorCode: number;
|
|
@@ -81,7 +82,7 @@ export interface CurrentUser {
|
|
|
81
82
|
permanent: boolean;
|
|
82
83
|
}
|
|
83
84
|
export interface UnlockMethodBaseInfo {
|
|
84
|
-
unlockId:
|
|
85
|
+
unlockId: number;
|
|
85
86
|
unlockName: string;
|
|
86
87
|
isBound: boolean;
|
|
87
88
|
id: number;
|
|
@@ -143,11 +144,13 @@ export type DpMapDataType<T extends DpMapType> = {
|
|
|
143
144
|
};
|
|
144
145
|
export interface NotifyInfo {
|
|
145
146
|
appSend?: boolean;
|
|
147
|
+
msgSend?: boolean;
|
|
146
148
|
msgPhone?: string;
|
|
147
149
|
countryCode?: string;
|
|
148
150
|
}
|
|
149
151
|
export interface UnlockMethodDetail {
|
|
150
152
|
isBound: boolean;
|
|
153
|
+
type: UnlockMethodType;
|
|
151
154
|
phase: number;
|
|
152
155
|
dpId: number;
|
|
153
156
|
isSpecial: boolean;
|
|
@@ -312,6 +315,10 @@ export interface DeviceAdvancedAbility {
|
|
|
312
315
|
support: boolean;
|
|
313
316
|
config: Record<string, any>;
|
|
314
317
|
};
|
|
318
|
+
unlockGuide: {
|
|
319
|
+
support: boolean;
|
|
320
|
+
config: Record<string, any>;
|
|
321
|
+
};
|
|
315
322
|
}
|
|
316
323
|
export interface OfflineDpInfo {
|
|
317
324
|
value: DpValue;
|
|
@@ -320,4 +327,9 @@ export interface OfflineDpInfo {
|
|
|
320
327
|
export interface OfflineDps {
|
|
321
328
|
[code: string]: OfflineDpInfo;
|
|
322
329
|
}
|
|
330
|
+
export interface UnlockGuide {
|
|
331
|
+
videoUrl: string;
|
|
332
|
+
picUrl: string;
|
|
333
|
+
expireTime: number;
|
|
334
|
+
}
|
|
323
335
|
export {};
|
package/lib/log.js
CHANGED
|
@@ -36,6 +36,12 @@ export const getLatestLogs = async () => {
|
|
|
36
36
|
catch {
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
let userName = item.userName;
|
|
40
|
+
let unlockName = item.unlockName;
|
|
41
|
+
if (item.dpId === 89 || item.dpId === 69) {
|
|
42
|
+
unlockName = item.userName;
|
|
43
|
+
userName = "";
|
|
44
|
+
}
|
|
39
45
|
return {
|
|
40
46
|
type,
|
|
41
47
|
logId: item.logId,
|
|
@@ -43,8 +49,8 @@ export const getLatestLogs = async () => {
|
|
|
43
49
|
dpCode,
|
|
44
50
|
data: itemData,
|
|
45
51
|
userId: item.userId,
|
|
46
|
-
userName
|
|
47
|
-
unlockName
|
|
52
|
+
userName,
|
|
53
|
+
unlockName,
|
|
48
54
|
mediaInfo: item.mediaInfoList,
|
|
49
55
|
unionUnlockInfo: item.unionUnlockInfo?.map((item1) => {
|
|
50
56
|
return {
|
|
@@ -142,6 +148,12 @@ export const getLogs = async (params) => {
|
|
|
142
148
|
if (dpCode === dpCodes.lockLocalRecord) {
|
|
143
149
|
type = "local_operation";
|
|
144
150
|
}
|
|
151
|
+
let userName = record.userName;
|
|
152
|
+
let unlockName = record.unlockName;
|
|
153
|
+
if (record.dpId === 89 || record.dpId === 69) {
|
|
154
|
+
unlockName = record.userName;
|
|
155
|
+
userName = "";
|
|
156
|
+
}
|
|
145
157
|
return {
|
|
146
158
|
type,
|
|
147
159
|
logId: record.historyId.toString(),
|
|
@@ -149,8 +161,8 @@ export const getLogs = async (params) => {
|
|
|
149
161
|
dpId: record.dpId,
|
|
150
162
|
data: dpValue,
|
|
151
163
|
dpCode,
|
|
152
|
-
userName
|
|
153
|
-
unlockName
|
|
164
|
+
userName,
|
|
165
|
+
unlockName,
|
|
154
166
|
mediaInfo: record.mediaInfoList,
|
|
155
167
|
unionUnlockInfo: record.unionUnlockInfo?.map((item) => ({
|
|
156
168
|
userId: item.userId,
|
package/lib/open.js
CHANGED
|
@@ -42,18 +42,18 @@ export const checkRemoteEnabled = parallelMerge(async () => {
|
|
|
42
42
|
if (deviceStatus.type !== "online") {
|
|
43
43
|
throw getError(1001);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const isLocalOnline = deviceStatus.onlineTypes.length === 1 &&
|
|
46
|
+
deviceStatus.onlineTypes.includes("local");
|
|
47
|
+
const isThreadLocalOnline = hasThread && isLocalOnline;
|
|
48
|
+
if (isThreadLocalOnline || deviceStatus.onlineTypes.includes("ble")) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (isLocalOnline) {
|
|
52
|
+
throw getError(1064);
|
|
49
53
|
}
|
|
50
54
|
if (dpSchema[dpCodes.remoteNoDpKey] === undefined) {
|
|
51
55
|
throw getError(1045);
|
|
52
56
|
}
|
|
53
|
-
if ((hasThread && deviceStatus.onlineType === "local") ||
|
|
54
|
-
deviceStatus.onlineType === "ble") {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
57
|
if (!remoteOpenEnabled) {
|
|
58
58
|
throw getError(1046);
|
|
59
59
|
}
|
|
@@ -65,7 +65,7 @@ export const checkRemoteEnabled = parallelMerge(async () => {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
const _doAction = async (isOpen, timeout) => {
|
|
68
|
-
const { devInfo,
|
|
68
|
+
const { devInfo, communication } = config;
|
|
69
69
|
await checkRemoteEnabled();
|
|
70
70
|
const deviceStatus = getDeviceStatus();
|
|
71
71
|
const hasThread = hasCapability(ProductCommunicationType.THREAD);
|
|
@@ -94,7 +94,7 @@ const _doAction = async (isOpen, timeout) => {
|
|
|
94
94
|
}
|
|
95
95
|
return false;
|
|
96
96
|
};
|
|
97
|
-
if (hasThread && deviceStatus.
|
|
97
|
+
if (hasThread && deviceStatus.onlineTypes.includes("local") && deviceStatus.onlineTypes.length === 1) {
|
|
98
98
|
await publishDps({ [dpCodes.matterLanUnlock]: isOpen }, {
|
|
99
99
|
checkReport: (dps) => {
|
|
100
100
|
return typeof dps[dpCodes.matterLanUnlock] !== "undefined";
|
package/lib/other.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export declare const connectDevice: () => Promise<unknown>;
|
|
|
27
27
|
export declare const gotoService: (params?: {
|
|
28
28
|
tab?: "cloudStorage" | "AI";
|
|
29
29
|
}) => Promise<unknown>;
|
|
30
|
+
export declare const validatePwdComplexity: (password: string) => Promise<boolean>;
|
|
30
31
|
export {};
|
package/lib/other.js
CHANGED
|
@@ -3,13 +3,14 @@ import config, { hasCapability, hasDp } from "./config";
|
|
|
3
3
|
import dpCodes from "./config/dp-code";
|
|
4
4
|
import { ProductCommunicationType } from "./constant";
|
|
5
5
|
import { getDeviceStatus, getDpValue } from "./state";
|
|
6
|
-
import { connectBLEDevice, getBLEOnlineState, navigateToMiniProgram, offBleChange, offOnlineChange, onBleChange, onOnlineChange, openPanel, } from "./utils/device";
|
|
6
|
+
import { connectBLEDevice, encrypt, getBLEOnlineState, navigateToMiniProgram, offBleChange, offOnlineChange, onBleChange, onOnlineChange, openPanel, } from "./utils/device";
|
|
7
7
|
import { getError } from "./utils/errors";
|
|
8
8
|
import { publishDps } from "./utils/publishDps";
|
|
9
9
|
import ipc from "./utils/ipc";
|
|
10
10
|
import { DPCHANGE } from "./utils/constant";
|
|
11
11
|
import emitter from "./utils/event";
|
|
12
12
|
import { getOfflineDpCache, publishOfflineDps } from "./offline-dps";
|
|
13
|
+
import { validatePasswordComplexity } from "./api/lock";
|
|
13
14
|
const { alarmLock, unlockFingerprint, unlockPassword, unlockCard, unlockKey, unlockPhoneRemote, unlockTemporary, unlockDynamic, unlockFace, unlockHand, unlockEye, unlockFingerVein, unlockInside, doorOpened, unlockApp, unlockOfflinePd, openInside, lockRecord, unlockDoubleKit, lockLocalRecord, wirelessAwake, } = dpCodes;
|
|
14
15
|
const abilityMap = {
|
|
15
16
|
backHome: "supportBackHome",
|
|
@@ -281,3 +282,10 @@ export const gotoService = async (params) => {
|
|
|
281
282
|
});
|
|
282
283
|
});
|
|
283
284
|
};
|
|
285
|
+
export const validatePwdComplexity = async (password) => {
|
|
286
|
+
const encryptedPassword = await encrypt(config.devInfo.devId, password);
|
|
287
|
+
return validatePasswordComplexity({
|
|
288
|
+
devId: config.devInfo.devId,
|
|
289
|
+
password: encryptedPassword,
|
|
290
|
+
});
|
|
291
|
+
};
|
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,7 +38,7 @@ 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,
|
|
@@ -46,26 +46,35 @@ export const getDeviceStatus = () => {
|
|
|
46
46
|
onlineTypes: [],
|
|
47
47
|
isWifiActive: wifiEnableState !== 1,
|
|
48
48
|
};
|
|
49
|
-
const isBleOnline =
|
|
49
|
+
const isBleOnline = isOnlineByType(onlineType, 2);
|
|
50
50
|
const isLocalOnline = !isCloudOnline && isOnlineByType(onlineType, 1);
|
|
51
51
|
const supportWifi = hasCapability(ProductCommunicationType.WIFI);
|
|
52
52
|
const supportBle = hasCapability(ProductCommunicationType.BLUETOOTH);
|
|
53
53
|
const supportThread = hasCapability(ProductCommunicationType.THREAD);
|
|
54
|
-
const hasWirelessAwakeDp =
|
|
54
|
+
const hasWirelessAwakeDp = hasDp(dpCodes.wirelessAwake);
|
|
55
55
|
const wirelessAwake = getDpValue(dpCodes.wirelessAwake);
|
|
56
|
-
const isDeviceOnline = hasWirelessAwakeDp
|
|
57
|
-
? wirelessAwake && isCloudOnline
|
|
58
|
-
: isCloudOnline;
|
|
59
56
|
status.connectEnable = isSupportBleControl() && !isOnline;
|
|
60
57
|
if (supportWifi) {
|
|
61
58
|
if (!status.connectEnable) {
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
if (isCloudOnline) {
|
|
60
|
+
status.connectEnable =
|
|
61
|
+
hasWirelessAwakeDp && wirelessAwake === false && !isBleOnline;
|
|
62
|
+
}
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
if (isOnline) {
|
|
67
|
-
if (
|
|
68
|
-
|
|
66
|
+
if (isCloudOnline) {
|
|
67
|
+
if (hasWirelessAwakeDp) {
|
|
68
|
+
if (wirelessAwake) {
|
|
69
|
+
status.onlineTypes.push("cloud");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
status.type = "offline";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
status.onlineTypes.push("cloud");
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
79
|
else if (isLocalOnline) {
|
|
71
80
|
status.onlineTypes.push("local");
|
|
@@ -190,24 +199,29 @@ export const permissions = [
|
|
|
190
199
|
"everyOne",
|
|
191
200
|
"noOne",
|
|
192
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
|
+
];
|
|
193
211
|
const fetchDeviceProperties = async (isForce) => {
|
|
194
212
|
let result = null;
|
|
195
213
|
if (isForce) {
|
|
196
|
-
result = await getDeviceProperties(config.devInfo.devId,
|
|
197
|
-
"REMOTE_UNLOCK_AUTH",
|
|
198
|
-
"UNLOCK_PHONE_REMOTE",
|
|
199
|
-
]);
|
|
214
|
+
result = await getDeviceProperties(config.devInfo.devId, propsList);
|
|
200
215
|
}
|
|
201
216
|
else {
|
|
202
217
|
result = await getDataWithPreFetch("getDeviceProperties", () => {
|
|
203
|
-
return getDeviceProperties(config.devInfo.devId,
|
|
204
|
-
"REMOTE_UNLOCK_AUTH",
|
|
205
|
-
"UNLOCK_PHONE_REMOTE",
|
|
206
|
-
]);
|
|
218
|
+
return getDeviceProperties(config.devInfo.devId, propsList);
|
|
207
219
|
});
|
|
208
220
|
}
|
|
209
|
-
config.remoteOpenEnabled =
|
|
210
|
-
|
|
221
|
+
config.remoteOpenEnabled =
|
|
222
|
+
result[DeviceProperties.UNLOCK_PHONE_REMOTE] === "true";
|
|
223
|
+
config.remoteOpenPermission =
|
|
224
|
+
permissions[+result[DeviceProperties.REMOTE_UNLOCK_AUTH] || 0];
|
|
211
225
|
};
|
|
212
226
|
export const initState = async () => {
|
|
213
227
|
const { devInfo: { dps, devId }, dpSchema, } = config;
|
package/lib/sync/temp.js
CHANGED
package/lib/temporary.js
CHANGED
|
@@ -10,19 +10,35 @@ 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,
|
|
@@ -144,7 +160,7 @@ export const createTempCustom = parallelOnly(async (params) => {
|
|
|
144
160
|
};
|
|
145
161
|
}
|
|
146
162
|
catch (error) {
|
|
147
|
-
throw handleError(error
|
|
163
|
+
throw handleError(error);
|
|
148
164
|
}
|
|
149
165
|
}
|
|
150
166
|
});
|
|
@@ -186,7 +202,7 @@ export const removeTempCustom = async (params) => {
|
|
|
186
202
|
}
|
|
187
203
|
}
|
|
188
204
|
catch (e) {
|
|
189
|
-
handleError(e
|
|
205
|
+
handleError(e);
|
|
190
206
|
}
|
|
191
207
|
};
|
|
192
208
|
export const updateTempCustom = async (params) => {
|
|
@@ -220,7 +236,7 @@ export const updateTempCustom = async (params) => {
|
|
|
220
236
|
});
|
|
221
237
|
}
|
|
222
238
|
catch (error) {
|
|
223
|
-
handleError(error
|
|
239
|
+
handleError(error);
|
|
224
240
|
}
|
|
225
241
|
};
|
|
226
242
|
const getOfflinePassword = async (params) => {
|
|
@@ -232,7 +248,7 @@ const getOfflinePassword = async (params) => {
|
|
|
232
248
|
};
|
|
233
249
|
}
|
|
234
250
|
catch (error) {
|
|
235
|
-
throw handleError(error
|
|
251
|
+
throw handleError(error);
|
|
236
252
|
}
|
|
237
253
|
};
|
|
238
254
|
export const createTempLimit = async (params) => {
|
|
@@ -500,7 +516,7 @@ const changePasswordPhase = async (unlockBindingId, phase) => {
|
|
|
500
516
|
});
|
|
501
517
|
}
|
|
502
518
|
catch (e) {
|
|
503
|
-
handleError(e
|
|
519
|
+
handleError(e);
|
|
504
520
|
}
|
|
505
521
|
return true;
|
|
506
522
|
};
|
|
@@ -582,7 +598,7 @@ export const saveTempOnlineUnlimited = async (params) => {
|
|
|
582
598
|
};
|
|
583
599
|
}
|
|
584
600
|
catch (error) {
|
|
585
|
-
throw handleError(error
|
|
601
|
+
throw handleError(error);
|
|
586
602
|
}
|
|
587
603
|
};
|
|
588
604
|
export const createTempOffline = async (params) => {
|
|
@@ -640,7 +656,7 @@ export const removeTempOnlineUnlimited = async (id) => {
|
|
|
640
656
|
});
|
|
641
657
|
}
|
|
642
658
|
catch (error) {
|
|
643
|
-
throw handleError(error
|
|
659
|
+
throw handleError(error);
|
|
644
660
|
}
|
|
645
661
|
};
|
|
646
662
|
const onLinePasswordStatusMap = {
|
|
@@ -674,7 +690,7 @@ export const getTempOnlineUnlimitedList = async () => {
|
|
|
674
690
|
return newPswList;
|
|
675
691
|
}
|
|
676
692
|
catch (error) {
|
|
677
|
-
throw handleError(error
|
|
693
|
+
throw handleError(error);
|
|
678
694
|
}
|
|
679
695
|
};
|
|
680
696
|
const offlinePasswordTypeMap = {
|
|
@@ -693,7 +709,7 @@ export const getTempOfflineEffectiveList = async (pwdTypeCode) => {
|
|
|
693
709
|
return offLineValidPswList;
|
|
694
710
|
}
|
|
695
711
|
catch (error) {
|
|
696
|
-
throw handleError(error
|
|
712
|
+
throw handleError(error);
|
|
697
713
|
}
|
|
698
714
|
};
|
|
699
715
|
export const getTempOfflineInvalidList = async (pwdTypeCode) => {
|
|
@@ -706,6 +722,6 @@ export const getTempOfflineInvalidList = async (pwdTypeCode) => {
|
|
|
706
722
|
return offLineFailurePswList;
|
|
707
723
|
}
|
|
708
724
|
catch (error) {
|
|
709
|
-
throw handleError(error
|
|
725
|
+
throw handleError(error);
|
|
710
726
|
}
|
|
711
727
|
};
|
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;
|
package/lib/user.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserDetail, getUserList } from "./api/user";
|
|
1
|
+
import { getUserDetail, getUserDetailQuery, getUserList, } from "./api/user";
|
|
2
2
|
import config from "./config";
|
|
3
3
|
import { update as updateMap, reportUpdate as reportUpdateMap, } from "./config/dp-map/unlock-method";
|
|
4
4
|
import { update as updateMapBig, reportUpdate as reportUpdateMapBig, } from "./config/dp-map/unlock-method-big";
|
|
@@ -14,58 +14,61 @@ import { LoopTypes } from "./utils/constant";
|
|
|
14
14
|
import { getCurrentUser } from "./state";
|
|
15
15
|
import { deleteUser } from "./utils/user";
|
|
16
16
|
import { UserType } from "./constant";
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
unlockId: unlockItem.unlockId.split("-")[1],
|
|
42
|
-
unlockName: unlockItem.unlockName,
|
|
43
|
-
id: unlockItem.opModeId,
|
|
44
|
-
isBound: unlockItem.allocateFlag === 1,
|
|
45
|
-
photoUnlock: unlockItem.photoUnlock,
|
|
46
|
-
isSpecial: unlockItem.unlockAttr === 1,
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
const unlockMethodConfig = unlockMethodConfigs.find((item) => item.code === detail.dpCode);
|
|
17
|
+
const handleUserDetail = (user) => {
|
|
18
|
+
const { timeScheduleInfo, unlockDetail, ...rest } = user;
|
|
19
|
+
let scheduleInfo = {
|
|
20
|
+
permanent: true,
|
|
21
|
+
};
|
|
22
|
+
if (!timeScheduleInfo.permanent &&
|
|
23
|
+
timeScheduleInfo.scheduleDetails &&
|
|
24
|
+
timeScheduleInfo.scheduleDetails.length > 0) {
|
|
25
|
+
Object.assign(scheduleInfo, {
|
|
26
|
+
permanent: false,
|
|
27
|
+
effectiveTime: formatTimestampToMilliseconds(timeScheduleInfo.effectiveTime || 0),
|
|
28
|
+
expiredTime: formatTimestampToMilliseconds(timeScheduleInfo.expiredTime || 0),
|
|
29
|
+
scheduleDetails: {
|
|
30
|
+
repeat: !timeScheduleInfo.scheduleDetails[0].allDay,
|
|
31
|
+
effectiveTime: timeScheduleInfo.scheduleDetails[0].effectiveTime,
|
|
32
|
+
invalidTime: timeScheduleInfo.scheduleDetails[0].invalidTime,
|
|
33
|
+
timeZoneId: timeScheduleInfo.scheduleDetails[0].timeZoneId,
|
|
34
|
+
weeks: parseWeek(timeScheduleInfo.scheduleDetails[0].workingDay),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let unlockDetails = unlockDetail.map((detail) => {
|
|
39
|
+
const unlockList = detail.unlockList.map((unlockItem) => {
|
|
50
40
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
unlockId: +unlockItem.unlockId.split("-")[1],
|
|
42
|
+
unlockName: unlockItem.unlockName,
|
|
43
|
+
id: unlockItem.opModeId,
|
|
44
|
+
isBound: unlockItem.allocateFlag === 1,
|
|
45
|
+
photoUnlock: unlockItem.photoUnlock,
|
|
46
|
+
isSpecial: unlockItem.unlockAttr === 1,
|
|
56
47
|
};
|
|
57
48
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
const unlockMethodConfig = unlockMethodConfigs.find((item) => item.code === detail.dpCode);
|
|
50
|
+
return {
|
|
51
|
+
count: unlockList.length,
|
|
52
|
+
dpCode: detail.dpCode,
|
|
53
|
+
dpId: detail.dpId,
|
|
54
|
+
type: unlockMethodConfig.type,
|
|
55
|
+
unlockList,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
...rest,
|
|
60
|
+
timeScheduleInfo: scheduleInfo,
|
|
61
|
+
unlockDetails,
|
|
62
|
+
isAccountUser: user.userListType === "group_user",
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const concactUserList = (list, result) => {
|
|
66
|
+
return list.reduce((acc, item) => {
|
|
67
|
+
acc.push(handleUserDetail(item));
|
|
64
68
|
return acc;
|
|
65
69
|
}, result);
|
|
66
70
|
};
|
|
67
|
-
|
|
68
|
-
const { page = 1, pageSize = 10, keyword = "" } = params || {};
|
|
71
|
+
const getUserDpCodes = async () => {
|
|
69
72
|
const currentUser = await getCurrentUser();
|
|
70
73
|
const dps = [];
|
|
71
74
|
if (currentUser.allOpenDps) {
|
|
@@ -77,6 +80,11 @@ export const getUsers = async (params) => {
|
|
|
77
80
|
return acc;
|
|
78
81
|
}, dps);
|
|
79
82
|
}
|
|
83
|
+
return dps;
|
|
84
|
+
};
|
|
85
|
+
export const getUsers = async (params) => {
|
|
86
|
+
const { page = 1, pageSize = 10, keyword = "" } = params || {};
|
|
87
|
+
const dps = await getUserDpCodes();
|
|
80
88
|
const res = await getUserList({
|
|
81
89
|
dpCodes: dps.join(","),
|
|
82
90
|
devId: config.devInfo.devId,
|
|
@@ -97,18 +105,13 @@ export const getUsers = async (params) => {
|
|
|
97
105
|
};
|
|
98
106
|
};
|
|
99
107
|
export const getUserInfo = async (params) => {
|
|
100
|
-
const
|
|
108
|
+
const currentUser = await getCurrentUser();
|
|
109
|
+
const res = await getUserDetailQuery({
|
|
101
110
|
devId: config.devInfo.devId,
|
|
102
111
|
userId: params.userId,
|
|
112
|
+
dpIds: currentUser.allOpenDps,
|
|
103
113
|
});
|
|
104
|
-
|
|
105
|
-
keyword: user.nickName,
|
|
106
|
-
});
|
|
107
|
-
const res = data.list.find((item) => item.userId === params.userId);
|
|
108
|
-
if (res) {
|
|
109
|
-
return res;
|
|
110
|
-
}
|
|
111
|
-
throw getError(1048);
|
|
114
|
+
return handleUserDetail(res);
|
|
112
115
|
};
|
|
113
116
|
export const updateUserLimitTime = async (params) => {
|
|
114
117
|
const { userId, lockUserId, permanent, effective } = params;
|
|
@@ -153,33 +156,33 @@ export const updateUserLimitTime = async (params) => {
|
|
|
153
156
|
endMinute: expiredTime % 60,
|
|
154
157
|
},
|
|
155
158
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (result.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
159
|
+
try {
|
|
160
|
+
const dpCode = config.supportBigData
|
|
161
|
+
? dpCodes.unlockMethodEditW
|
|
162
|
+
: dpCodes.unlockMethodEdit;
|
|
163
|
+
const res = (await publishDps({
|
|
164
|
+
[dpCode]: DpUtils.format(dpValue, (config.supportBigData ? updateMapBig : updateMap)),
|
|
165
|
+
}, {
|
|
166
|
+
checkReport: (dps) => {
|
|
167
|
+
if (typeof dps[dpCode] !== "undefined") {
|
|
168
|
+
const result = DpUtils.parse(dps[dpCode], (config.supportBigData
|
|
169
|
+
? reportUpdateMapBig
|
|
170
|
+
: reportUpdateMap));
|
|
171
|
+
if (result.type === 0) {
|
|
172
|
+
if (result.memberId === lockUserId) {
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
console.warn("An incorrect member id was returned");
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
try {
|
|
180
|
+
return false;
|
|
181
|
+
},
|
|
182
|
+
}));
|
|
183
|
+
if (res.status !== 255) {
|
|
184
|
+
throw getError(1011);
|
|
185
|
+
}
|
|
183
186
|
await updateUserTimeSchedule({
|
|
184
187
|
devId: config.devInfo.devId,
|
|
185
188
|
userId: userId,
|
|
@@ -241,11 +244,8 @@ export const openFamilyUserDetail = async (userId) => {
|
|
|
241
244
|
const url = `tuyaSmart://member_info?homeId=${homeId}&memberId=${userId}&role=${role}`;
|
|
242
245
|
ty.router({
|
|
243
246
|
url: url,
|
|
244
|
-
success: (d) => {
|
|
245
|
-
console.log("openFamilyUserDetail success");
|
|
246
|
-
},
|
|
247
247
|
fail: (e) => {
|
|
248
|
-
console.
|
|
248
|
+
console.error("openFamilyUserDetail fail", e);
|
|
249
249
|
},
|
|
250
250
|
});
|
|
251
251
|
return;
|
package/lib/utils/errors.js
CHANGED
|
@@ -64,6 +64,8 @@ const errors = {
|
|
|
64
64
|
1063: "Password length only supports 4-6 digits",
|
|
65
65
|
1064: "Non-thread device, not supported in LAN connection to open and close locks",
|
|
66
66
|
1065: "Cloud side has been deleted, but device side synchronization deletion failed",
|
|
67
|
+
1066: "Phone number cannot be empty",
|
|
68
|
+
1067: "Password limit reached within this period",
|
|
67
69
|
};
|
|
68
70
|
export const getError = (code, ...places) => {
|
|
69
71
|
if (errors[code]) {
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export declare const parseOfflinePassword: (value: string) => string;
|
|
|
107
107
|
export declare const formatTimestampToMilliseconds: (timestamp: number) => number;
|
|
108
108
|
export declare const unlockMethodConfigs: UnlockMethodConfig[];
|
|
109
109
|
export declare const getUnlockMethodTypeByDpCode: (dpCode: string) => UnlockMethodConfig;
|
|
110
|
-
export declare const getUnlockMethodTypeById: (id: number) => UnlockMethodConfig;
|
|
110
|
+
export declare const getUnlockMethodTypeById: (id: number | string) => UnlockMethodConfig;
|
|
111
111
|
export declare const getUnlockMethodTypeByType: (type: string) => UnlockMethodConfig;
|
|
112
112
|
export declare const parallelMerge: <T extends (...args: any[]) => Promise<any>>(cb: T) => (...args: Parameters<T>) => ReturnType<T>;
|
|
113
113
|
export declare const parallelOnly: <T extends (...args: any[]) => Promise<any>>(cb: T) => (...args: Parameters<T>) => ReturnType<T>;
|
package/lib/utils/index.js
CHANGED
|
@@ -49,7 +49,8 @@ export function getCapabilities(capability) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
export const formatWeek = (value) => {
|
|
52
|
-
|
|
52
|
+
const temp = value.slice(0, 7);
|
|
53
|
+
return parseInt(temp.reverse().join(""), 2);
|
|
53
54
|
};
|
|
54
55
|
export const parseWeek = (value) => {
|
|
55
56
|
return Number(value)
|
|
@@ -258,18 +259,20 @@ onBackgroundFetchData(preFetchKeys, (res) => {
|
|
|
258
259
|
});
|
|
259
260
|
});
|
|
260
261
|
export const getDataWithPreFetch = async (key, apiCb) => {
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
result
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
if (config.preFetch) {
|
|
263
|
+
if (preFetchData[key]) {
|
|
264
|
+
return preFetchData[key];
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const result = await getBackgroundFetchData([key]);
|
|
268
|
+
if (result &&
|
|
269
|
+
result.fetchedData[key] &&
|
|
270
|
+
result.fetchedData[key].fetchedData) {
|
|
271
|
+
return result.fetchedData[key].fetchedData;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
270
275
|
}
|
|
271
|
-
}
|
|
272
|
-
catch {
|
|
273
276
|
}
|
|
274
277
|
return apiCb();
|
|
275
278
|
};
|