@ray-js/lock-sdk 1.1.1-beta.8 → 1.1.1-beta.9

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/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,7 +40,14 @@ export const getUserList = (params) => {
40
40
  };
41
41
  export const getUserDetail = (params) => {
42
42
  return requestApi({
43
- api: 'm.lock.device.member.detail',
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",
44
51
  version: "1.0",
45
52
  data: params,
46
53
  });
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/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<UserInfo>;
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,59 +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 concactUserList = (list, result) => {
18
- return list.reduce((acc, item) => {
19
- const { timeScheduleInfo, unlockDetail, ...rest } = item;
20
- let scheduleInfo = {
21
- permanent: true,
22
- };
23
- if (!item.timeScheduleInfo.permanent &&
24
- item.timeScheduleInfo.scheduleDetails &&
25
- item.timeScheduleInfo.scheduleDetails.length > 0) {
26
- Object.assign(scheduleInfo, {
27
- permanent: false,
28
- effectiveTime: formatTimestampToMilliseconds(item.timeScheduleInfo.effectiveTime || 0),
29
- expiredTime: formatTimestampToMilliseconds(item.timeScheduleInfo.expiredTime || 0),
30
- scheduleDetails: {
31
- repeat: !item.timeScheduleInfo.scheduleDetails[0].allDay,
32
- effectiveTime: item.timeScheduleInfo.scheduleDetails[0].effectiveTime,
33
- invalidTime: item.timeScheduleInfo.scheduleDetails[0].invalidTime,
34
- timeZoneId: item.timeScheduleInfo.scheduleDetails[0].timeZoneId,
35
- weeks: parseWeek(item.timeScheduleInfo.scheduleDetails[0].workingDay),
36
- },
37
- });
38
- }
39
- let unlockDetails = unlockDetail.map((detail) => {
40
- const unlockList = detail.unlockList.map((unlockItem) => {
41
- return {
42
- unlockId: +unlockItem.unlockId.split("-")[1],
43
- unlockName: unlockItem.unlockName,
44
- id: unlockItem.opModeId,
45
- isBound: unlockItem.allocateFlag === 1,
46
- photoUnlock: unlockItem.photoUnlock,
47
- isSpecial: unlockItem.unlockAttr === 1,
48
- };
49
- });
50
- 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) => {
51
40
  return {
52
- count: unlockList.length,
53
- dpCode: detail.dpCode,
54
- dpId: detail.dpId,
55
- type: unlockMethodConfig.type,
56
- unlockList,
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,
57
47
  };
58
48
  });
59
- acc.push({
60
- ...rest,
61
- timeScheduleInfo: scheduleInfo,
62
- unlockDetails,
63
- isAccountUser: item.userListType === "group_user",
64
- });
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));
65
68
  return acc;
66
69
  }, result);
67
70
  };
68
- export const getUsers = async (params) => {
69
- const { page = 1, pageSize = 10, keyword = "" } = params || {};
71
+ const getUserDpCodes = async () => {
70
72
  const currentUser = await getCurrentUser();
71
73
  const dps = [];
72
74
  if (currentUser.allOpenDps) {
@@ -78,6 +80,11 @@ export const getUsers = async (params) => {
78
80
  return acc;
79
81
  }, dps);
80
82
  }
83
+ return dps;
84
+ };
85
+ export const getUsers = async (params) => {
86
+ const { page = 1, pageSize = 10, keyword = "" } = params || {};
87
+ const dps = await getUserDpCodes();
81
88
  const res = await getUserList({
82
89
  dpCodes: dps.join(","),
83
90
  devId: config.devInfo.devId,
@@ -98,18 +105,13 @@ export const getUsers = async (params) => {
98
105
  };
99
106
  };
100
107
  export const getUserInfo = async (params) => {
101
- const user = await getUserDetail({
108
+ const currentUser = await getCurrentUser();
109
+ const res = await getUserDetailQuery({
102
110
  devId: config.devInfo.devId,
103
111
  userId: params.userId,
112
+ dpIds: currentUser.allOpenDps,
104
113
  });
105
- const data = await getUsers({
106
- keyword: user.nickName,
107
- });
108
- const res = data.list.find((item) => item.userId === params.userId);
109
- if (res) {
110
- return res;
111
- }
112
- throw getError(1048);
114
+ return handleUserDetail(res);
113
115
  };
114
116
  export const updateUserLimitTime = async (params) => {
115
117
  const { userId, lockUserId, permanent, effective } = params;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.1.1-beta.8",
3
+ "version": "1.1.1-beta.9",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"