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

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/user.d.ts CHANGED
@@ -82,26 +82,6 @@ export declare const getUserList: (params: getUserListParams) => Promise<{
82
82
  user: UserListItem[];
83
83
  hasNext: boolean;
84
84
  }>;
85
- interface GetUserDetailParams {
86
- devId: string;
87
- userId: string;
88
- }
89
- interface UserDetail {
90
- allOpenType: number[];
91
- avatarUrl: string;
92
- lockUserId: number;
93
- nickName: string;
94
- phase: number;
95
- productAttribute: number;
96
- status: number;
97
- supportOpenType: number[];
98
- uid: string;
99
- userContact: string;
100
- userId: string;
101
- userTimeSet: string;
102
- userType: number;
103
- }
104
- export declare const getUserDetail: (params: GetUserDetailParams) => Promise<UserDetail>;
105
85
  interface GetUserDetailQueryParams {
106
86
  devId: string;
107
87
  userId: string;
package/lib/api/user.js CHANGED
@@ -38,13 +38,6 @@ export const getUserList = (params) => {
38
38
  data: params,
39
39
  });
40
40
  };
41
- export const getUserDetail = (params) => {
42
- return requestApi({
43
- api: "m.lock.device.member.detail",
44
- version: "1.0",
45
- data: params,
46
- });
47
- };
48
41
  export const getUserDetailQuery = (params) => {
49
42
  return requestApi({
50
43
  api: "m.lock.user.detail.query",
@@ -55,7 +48,7 @@ export const getUserDetailQuery = (params) => {
55
48
  export const getUsersSyncLockData = (deviceId) => {
56
49
  return requestApi({
57
50
  api: `${THING}.m.device.lock.sync.batch`,
58
- version: "2.0",
51
+ version: "1.0",
59
52
  data: {
60
53
  devId: deviceId,
61
54
  },
@@ -64,7 +57,7 @@ export const getUsersSyncLockData = (deviceId) => {
64
57
  export const removeUser = (devId, userId) => {
65
58
  return requestApi({
66
59
  api: `${THING}.m.device.member.remove`,
67
- version: "2.0",
60
+ version: "1.0",
68
61
  data: {
69
62
  devId,
70
63
  userId,
package/lib/capability.js CHANGED
@@ -8,7 +8,7 @@ export const isActiveThread = async () => {
8
8
  const hasThread = hasCapability(ProductCommunicationType.THREAD);
9
9
  if (hasThread) {
10
10
  const deviceStatus = getDeviceStatus();
11
- if (deviceStatus.onlineType === "cloud" ||
11
+ if (deviceStatus.onlineTypes.includes("cloud") ||
12
12
  config.communication.length === 1) {
13
13
  return true;
14
14
  }
@@ -89,7 +89,7 @@ const reportAdd = [
89
89
  const remove = [
90
90
  ...common,
91
91
  {
92
- name: "category",
92
+ name: "operation",
93
93
  },
94
94
  ];
95
95
  const reportRemove = [
@@ -161,7 +161,7 @@ declare const remove: readonly [{
161
161
  }, {
162
162
  readonly name: "unlockId";
163
163
  }, {
164
- readonly name: "target";
164
+ readonly name: "operation";
165
165
  }];
166
166
  declare const reportRemove: ({
167
167
  readonly name: "type";
@@ -176,7 +176,7 @@ declare const reportRemove: ({
176
176
  } | {
177
177
  readonly name: "unlockId";
178
178
  } | {
179
- readonly name: "target";
179
+ readonly name: "operation";
180
180
  } | {
181
181
  name: string;
182
182
  })[];
@@ -649,7 +649,7 @@ declare const _default: {
649
649
  }, {
650
650
  readonly name: "unlockId";
651
651
  }, {
652
- readonly name: "target";
652
+ readonly name: "operation";
653
653
  }];
654
654
  reportRemove: ({
655
655
  readonly name: "type";
@@ -664,7 +664,7 @@ declare const _default: {
664
664
  } | {
665
665
  readonly name: "unlockId";
666
666
  } | {
667
- readonly name: "target";
667
+ readonly name: "operation";
668
668
  } | {
669
669
  name: string;
670
670
  })[];
@@ -87,7 +87,7 @@ const reportAdd = [
87
87
  const remove = [
88
88
  ...common,
89
89
  {
90
- name: "target",
90
+ name: "operation",
91
91
  },
92
92
  ];
93
93
  const reportRemove = [
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { hasCapability, hasDp, updateConfig } from "./config";
2
2
  import { LockSDKOption } from "./interface";
3
3
  import { getCurrentUser, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, getCurrentUserSync, getMediaRotate } from "./state";
4
4
  import { syncUnlockMethod } from "./sync/unlock-method";
5
+ import syncDeleteUsers from "./sync/user";
5
6
  import { publishDps } from "./utils/publishDps";
6
7
  import { publishOfflineDps, getOfflineDps, isOfflineDpSyncing, onOfflineDpsUpdate, offOfflineDpsUpdate, getOfflineDpCache } from "./offline-dps";
7
8
  export * from "./user";
@@ -19,4 +20,4 @@ export * from "./linkage";
19
20
  export * from "./capability";
20
21
  export declare const init: (options?: LockSDKOption) => Promise<void>;
21
22
  export declare const destroy: () => void;
22
- export { getCurrentUser, getMediaRotate, getCurrentUserSync, syncUnlockMethod, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, updateConfig, hasCapability, hasDp, publishDps, publishOfflineDps, getOfflineDps, isOfflineDpSyncing, onOfflineDpsUpdate, offOfflineDpsUpdate, getOfflineDpCache, };
23
+ export { getCurrentUser, getMediaRotate, getCurrentUserSync, syncUnlockMethod, syncDeleteUsers, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, updateConfig, hasCapability, hasDp, publishDps, publishOfflineDps, getOfflineDps, isOfflineDpSyncing, onOfflineDpsUpdate, offOfflineDpsUpdate, getOfflineDpCache, };
package/lib/index.js CHANGED
@@ -2,8 +2,9 @@ import config, { hasCapability, hasDp, updateConfig } from "./config";
2
2
  import dpCodes from "./config/dp-code";
3
3
  import { addEvents, clearState, initState, removeEvents, getCurrentUser, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, getCurrentUserSync, getMediaRotate, } from "./state";
4
4
  import { getCapabilities } from "./utils";
5
- import { getDeviceInfo, getLaunchOptionsSync } from "./utils/device";
5
+ import { getDeviceInfo, getLaunchOptionsSync, trackEvent, } from "./utils/device";
6
6
  import { syncUnlockMethod } from "./sync/unlock-method";
7
+ import syncDeleteUsers from "./sync/user";
7
8
  import { publishDps } from "./utils/publishDps";
8
9
  import { publishOfflineDps, getOfflineDps, isOfflineDpSyncing, onOfflineDpsUpdate, offOfflineDpsUpdate, getOfflineDpCache, } from "./offline-dps";
9
10
  export * from "./user";
@@ -63,10 +64,13 @@ export const init = async (options) => {
63
64
  config.preFetch = options?.preFetch ?? false;
64
65
  config.communication = getCapabilities(devInfo.capability).map((item) => item.id);
65
66
  addEvents();
67
+ trackEvent("t$y_UztB3Lj9Qns375R0r7dA0L5Kr2VytH3J".replace("$", ""), {
68
+ pid: devInfo.productId,
69
+ });
66
70
  await initState();
67
71
  };
68
72
  export const destroy = () => {
69
73
  clearState();
70
74
  removeEvents();
71
75
  };
72
- export { getCurrentUser, getMediaRotate, getCurrentUserSync, syncUnlockMethod, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, updateConfig, hasCapability, hasDp, publishDps, publishOfflineDps, getOfflineDps, isOfflineDpSyncing, onOfflineDpsUpdate, offOfflineDpsUpdate, getOfflineDpCache, };
76
+ export { getCurrentUser, getMediaRotate, getCurrentUserSync, syncUnlockMethod, syncDeleteUsers, getDeviceStatus, onDeviceStatusChange, offDeviceStatusChange, updateConfig, hasCapability, hasDp, publishDps, publishOfflineDps, getOfflineDps, isOfflineDpSyncing, onOfflineDpsUpdate, offOfflineDpsUpdate, getOfflineDpCache, };
@@ -29,14 +29,14 @@ export const checkOfflineDpUpdate = async (dps, isForce) => {
29
29
  if (!config.supportOfflineDps) {
30
30
  return;
31
31
  }
32
- const hasOne = Object.keys(dps).some((code) => cache[code]?.pushStatus === false);
32
+ const hasOne = Object.keys(dps).some((code) => cache?.[code]?.pushStatus === false);
33
33
  if (hasOne || isForce) {
34
34
  const res = await getOfflineDps(true);
35
35
  emitter.emit(OFFLINE_DPS_UPDATE, res);
36
36
  }
37
37
  };
38
38
  export const getOfflineDpCache = (code) => {
39
- return cache[code];
39
+ return cache?.[code];
40
40
  };
41
41
  export const publishOfflineDps = async (dps) => {
42
42
  const { devInfo, dpSchema } = config;
@@ -52,20 +52,12 @@ export const publishOfflineDps = async (dps) => {
52
52
  return acc;
53
53
  }, {});
54
54
  await publishOfflineDpData(devInfo.devId, dpData);
55
- try {
56
- await checkOfflineDpUpdate({}, true);
57
- }
58
- catch {
59
- }
55
+ checkOfflineDpUpdate({}, true);
60
56
  };
61
57
  export const clearOfflineDps = async () => {
62
58
  const { devInfo } = config;
63
59
  await clearOfflineDpData(devInfo.devId);
64
- try {
65
- await checkOfflineDpUpdate({}, true);
66
- }
67
- catch {
68
- }
60
+ checkOfflineDpUpdate({}, true);
69
61
  };
70
62
  const OFFLINE_DPS_UPDATE = "offline_dps_update";
71
63
  export const onOfflineDpsUpdate = (callback) => {
@@ -0,0 +1,4 @@
1
+ export declare const isDedicatedBleHexSuccess: (raw: string) => boolean;
2
+ export declare const resolveDedicatedBleCommandDp: () => string | null;
3
+ export declare const executeDedicatedBleManualLock: (timeout: number) => Promise<void>;
4
+ export declare const executeDedicatedBleRawAction: (isOpen: boolean, timeout: number) => Promise<void>;
@@ -0,0 +1,148 @@
1
+ import dpUtils from "@ray-js/tuya-dp-transform";
2
+ import { getDoorKey } from "../api/lock";
3
+ import config, { hasDp } from "../config";
4
+ import dpCodes from "../config/dp-code";
5
+ import { open as openMap, reportOpen as reportOpenMap, } from "../config/dp-map/open";
6
+ import syncRemoteSerectKey from "../sync/remote-serect-key";
7
+ import { stringToBytes } from "../utils/byte";
8
+ import { decrypt } from "../utils/device";
9
+ import { getError } from "../utils/errors";
10
+ import { publishDps } from "../utils/publishDps";
11
+ import { getOpenDoorMemberId } from "./ble-remote-no-dp-key";
12
+ import { mapRemoteOpenReportStatus } from "./report-status";
13
+ const normalizeHex = (raw) => raw.replace(/\s/g, "").toLowerCase();
14
+ export const isDedicatedBleHexSuccess = (raw) => {
15
+ const n = normalizeHex(raw);
16
+ if (n.length < 2) {
17
+ return false;
18
+ }
19
+ return n.startsWith("00") || n.endsWith("00");
20
+ };
21
+ const parseDedicatedBleHexStatus = (raw) => {
22
+ const n = normalizeHex(raw);
23
+ if (n.length < 2) {
24
+ return false;
25
+ }
26
+ if (isDedicatedBleHexSuccess(raw)) {
27
+ return { status: 0 };
28
+ }
29
+ if (n.includes("06")) {
30
+ return { status: 0x06 };
31
+ }
32
+ return { status: 0x01 };
33
+ };
34
+ const tryParseStandardUnlockReport = (raw, memberId) => {
35
+ try {
36
+ const result = dpUtils.parse(raw, reportOpenMap);
37
+ if (result.memberId !== memberId) {
38
+ return false;
39
+ }
40
+ if (hasDp(dpCodes.lockMotorState) && result.status === 0) {
41
+ return false;
42
+ }
43
+ return result;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ };
49
+ export const resolveDedicatedBleCommandDp = () => {
50
+ if (hasDp(dpCodes.bleUnlockCheck)) {
51
+ return dpCodes.bleUnlockCheck;
52
+ }
53
+ if (hasDp(dpCodes.bluetoothUnlock)) {
54
+ return dpCodes.bluetoothUnlock;
55
+ }
56
+ if (hasDp(dpCodes.unlockBle)) {
57
+ return dpCodes.unlockBle;
58
+ }
59
+ return null;
60
+ };
61
+ const createDedicatedBleCheckReport = (commandDp, memberId) => {
62
+ return (dpData) => {
63
+ if (hasDp(dpCodes.lockMotorState)) {
64
+ if (typeof dpData[dpCodes.lockMotorState] !== "undefined") {
65
+ return { status: 0 };
66
+ }
67
+ }
68
+ if (typeof dpData[commandDp] !== "undefined") {
69
+ const raw = dpData[commandDp];
70
+ const standard = tryParseStandardUnlockReport(raw, memberId);
71
+ if (standard) {
72
+ return standard;
73
+ }
74
+ const hexStatus = parseDedicatedBleHexStatus(raw);
75
+ if (hexStatus !== false) {
76
+ return hexStatus;
77
+ }
78
+ }
79
+ if (typeof dpData[dpCodes.remoteNoDpKey] !== "undefined") {
80
+ const result = dpUtils.parse(dpData[dpCodes.remoteNoDpKey], reportOpenMap);
81
+ if (result.memberId === memberId) {
82
+ if (hasDp(dpCodes.lockMotorState) && result.status === 0) {
83
+ return false;
84
+ }
85
+ return result;
86
+ }
87
+ }
88
+ return false;
89
+ };
90
+ };
91
+ export const executeDedicatedBleManualLock = async (timeout) => {
92
+ if (!hasDp(dpCodes.manualLock)) {
93
+ throw getError(1014);
94
+ }
95
+ await publishDps({
96
+ [dpCodes.manualLock]: true,
97
+ }, {
98
+ timeout,
99
+ checkReport: (dpData) => {
100
+ if (hasDp(dpCodes.lockMotorState)) {
101
+ if (typeof dpData[dpCodes.lockMotorState] !== "undefined") {
102
+ return { status: 0 };
103
+ }
104
+ }
105
+ if (typeof dpData[dpCodes.manualLock] !== "undefined") {
106
+ return { status: 0 };
107
+ }
108
+ return false;
109
+ },
110
+ });
111
+ };
112
+ export const executeDedicatedBleRawAction = async (isOpen, timeout) => {
113
+ if (!isOpen && hasDp(dpCodes.manualLock)) {
114
+ await executeDedicatedBleManualLock(timeout);
115
+ return;
116
+ }
117
+ const commandDp = resolveDedicatedBleCommandDp();
118
+ if (!commandDp) {
119
+ throw getError(1014);
120
+ }
121
+ await syncRemoteSerectKey();
122
+ let pw = "";
123
+ try {
124
+ const { password } = await getDoorKey(config.devInfo.devId);
125
+ pw = await decrypt(config.devInfo.devId, password);
126
+ }
127
+ catch {
128
+ await syncRemoteSerectKey(true);
129
+ const { password } = await getDoorKey(config.devInfo.devId);
130
+ pw = await decrypt(config.devInfo.devId, password);
131
+ }
132
+ const memberId = await getOpenDoorMemberId();
133
+ const payload = dpUtils.format({
134
+ status: Number(isOpen),
135
+ memberId,
136
+ key: stringToBytes(pw),
137
+ type: 3,
138
+ }, openMap);
139
+ const response = (await publishDps({
140
+ [commandDp]: payload,
141
+ }, {
142
+ timeout,
143
+ checkReport: createDedicatedBleCheckReport(commandDp, memberId),
144
+ }));
145
+ if (response.status !== 0) {
146
+ throw mapRemoteOpenReportStatus(response.status);
147
+ }
148
+ };
@@ -0,0 +1,4 @@
1
+ import { DpValue } from "../interface";
2
+ export declare const createRemoteNoDpKeyBleCheckReport: (memberId: number) => (dpData: Record<string, DpValue>) => any;
3
+ export declare const executeBleRemoteNoDpKeyAction: (isOpen: boolean, timeout: number, memberId: number) => Promise<void>;
4
+ export declare const getOpenDoorMemberId: () => Promise<number>;
@@ -0,0 +1,69 @@
1
+ import dpUtils from "@ray-js/tuya-dp-transform";
2
+ import { getDoorKey } from "../api/lock";
3
+ import config, { hasDp } from "../config";
4
+ import dpCodes from "../config/dp-code";
5
+ import { open as openMap, reportOpen as reportOpenMap, } from "../config/dp-map/open";
6
+ import { getCurrentUser } from "../state";
7
+ import syncRemoteSerectKey from "../sync/remote-serect-key";
8
+ import { stringToBytes } from "../utils/byte";
9
+ import { decrypt } from "../utils/device";
10
+ import { publishDps } from "../utils/publishDps";
11
+ import { mapRemoteOpenReportStatus } from "./report-status";
12
+ export const createRemoteNoDpKeyBleCheckReport = (memberId) => {
13
+ return (dpData) => {
14
+ if (hasDp(dpCodes.lockMotorState)) {
15
+ if (typeof dpData[dpCodes.lockMotorState] !== "undefined") {
16
+ return {
17
+ status: 0,
18
+ };
19
+ }
20
+ }
21
+ if (typeof dpData[dpCodes.remoteNoDpKey] !== "undefined") {
22
+ const result = dpUtils.parse(dpData[dpCodes.remoteNoDpKey], reportOpenMap);
23
+ if (result.memberId === memberId) {
24
+ if (hasDp(dpCodes.lockMotorState) && result.status === 0) {
25
+ return false;
26
+ }
27
+ return result;
28
+ }
29
+ else {
30
+ console.warn("An incorrect member id was returned");
31
+ }
32
+ }
33
+ return false;
34
+ };
35
+ };
36
+ export const executeBleRemoteNoDpKeyAction = async (isOpen, timeout, memberId) => {
37
+ await syncRemoteSerectKey();
38
+ let pw = "";
39
+ try {
40
+ const { password } = await getDoorKey(config.devInfo.devId);
41
+ pw = await decrypt(config.devInfo.devId, password);
42
+ }
43
+ catch {
44
+ await syncRemoteSerectKey(true);
45
+ const { password } = await getDoorKey(config.devInfo.devId);
46
+ pw = await decrypt(config.devInfo.devId, password);
47
+ }
48
+ const response = (await publishDps({
49
+ [dpCodes.remoteNoDpKey]: dpUtils.format({
50
+ status: Number(isOpen),
51
+ memberId,
52
+ key: stringToBytes(pw),
53
+ type: 3,
54
+ }, openMap),
55
+ }, {
56
+ timeout,
57
+ checkReport: createRemoteNoDpKeyBleCheckReport(memberId),
58
+ }));
59
+ if (response.status !== 0) {
60
+ throw mapRemoteOpenReportStatus(response.status);
61
+ }
62
+ };
63
+ export const getOpenDoorMemberId = async () => {
64
+ const currentUser = await getCurrentUser();
65
+ if (currentUser.lockUserId !== 0) {
66
+ return Number(currentUser.lockUserId);
67
+ }
68
+ return Number(currentUser.userId);
69
+ };
@@ -0,0 +1 @@
1
+ export declare const mapRemoteOpenReportStatus: (status: number) => import("..").ErrorData;
@@ -0,0 +1,23 @@
1
+ import { getError } from "../utils/errors";
2
+ export const mapRemoteOpenReportStatus = (status) => {
3
+ let error = getError(1004);
4
+ switch (status) {
5
+ case 0x02:
6
+ error = getError(1005);
7
+ break;
8
+ case 0x03:
9
+ error = getError(1006);
10
+ break;
11
+ case 0x04:
12
+ error = getError(1007);
13
+ break;
14
+ case 0x05:
15
+ error = getError(1008);
16
+ break;
17
+ case 0x06:
18
+ error = getError(1070);
19
+ break;
20
+ default:
21
+ }
22
+ return error;
23
+ };
package/lib/other.js CHANGED
@@ -260,7 +260,7 @@ export const connectDevice = async () => {
260
260
  }
261
261
  }
262
262
  if (isSupportBleControl()) {
263
- if (deviceStatus.type === "online" && deviceStatus.onlineType === "ble") {
263
+ if (deviceStatus.type === "online" && deviceStatus.onlineTypes.includes("ble")) {
264
264
  return true;
265
265
  }
266
266
  return await connectBle();
package/lib/state.js CHANGED
@@ -243,12 +243,14 @@ export const initState = async () => {
243
243
  fetchDeviceProperties();
244
244
  getDeviceAdvancedAbilities();
245
245
  syncRemoteSerectKey();
246
+ checkOfflineDpUpdate({}, true).then(() => {
247
+ setTimeout(() => {
248
+ syncOfflineDps();
249
+ }, 3000);
250
+ });
246
251
  setTimeout(() => {
247
252
  syncT0();
248
253
  autoSyncUnlockMethod();
249
- checkOfflineDpUpdate({}, true).then(() => {
250
- syncOfflineDps();
251
- });
252
254
  }, 2000);
253
255
  setTimeout(() => {
254
256
  autoSyncTemp();
@@ -295,6 +297,9 @@ const handleAppShow = () => {
295
297
  getCurrentUser(true);
296
298
  fetchDeviceProperties();
297
299
  checkOfflineDpUpdate({}, true);
300
+ setTimeout(() => {
301
+ syncDeleteUsers();
302
+ }, 1000);
298
303
  };
299
304
  const handleAppHide = () => { };
300
305
  export const addEvents = () => {
@@ -12,12 +12,7 @@ export const syncOfflineDps = async () => {
12
12
  if (Object.keys(offlineDps).length) {
13
13
  const hasTask = Object.keys(offlineDps).some((code) => offlineDps[code].pushStatus === false);
14
14
  if (hasTask) {
15
- try {
16
- await clearOfflineDpData(config.devInfo.devId);
17
- }
18
- catch (error) {
19
- return;
20
- }
15
+ clearOfflineDpData(config.devInfo.devId);
21
16
  const dpData = Object.keys(offlineDps).reduce((acc, code) => {
22
17
  acc[code] = offlineDps[code].value;
23
18
  return acc;
@@ -18,25 +18,25 @@ export const syncUnlockMethod = async () => {
18
18
  const dpCode = config.supportBigData
19
19
  ? dpCodes.synchMethodW
20
20
  : dpCodes.synchMethod;
21
- await publishDps({ [dpCode]: ins }, {
22
- checkReport: (dpData) => {
23
- if (typeof dpData[dpCode] !== "undefined") {
24
- const result = dpUtils.parse(dpData[dpCode], config.supportBigData ? reportSyncBigMap : reportSyncMap);
25
- if (result.stage === 1) {
26
- return true;
21
+ try {
22
+ await publishDps({ [dpCode]: ins }, {
23
+ checkReport: (dpData) => {
24
+ if (typeof dpData[dpCode] !== "undefined") {
25
+ const result = dpUtils.parse(dpData[dpCode], config.supportBigData ? reportSyncBigMap : reportSyncMap);
26
+ if (result.stage === 1) {
27
+ return true;
28
+ }
27
29
  }
28
- }
29
- return false;
30
- },
31
- });
30
+ return false;
31
+ },
32
+ });
33
+ }
34
+ catch (error) {
35
+ }
32
36
  }
33
37
  };
34
38
  export const autoSyncUnlockMethod = async () => {
35
- try {
36
- if (syncUnlockMethodFirst) {
37
- await syncUnlockMethod();
38
- }
39
- }
40
- catch (e) {
39
+ if (syncUnlockMethodFirst) {
40
+ await syncUnlockMethod();
41
41
  }
42
42
  };
package/lib/sync/user.js CHANGED
@@ -1,40 +1,65 @@
1
1
  import { getDeviceStatus } from "../state";
2
- import { ProductCommunicationType } from "../constant";
3
- import config, { hasCapability } from "../config";
2
+ import config from "../config";
4
3
  import { getUsersSyncLockData } from "../api/user";
5
4
  import { deleteUser } from "../utils/user";
6
- let isSyncDone = false;
5
+ import { isUseNearChannel } from "../utils";
6
+ let isSyncing = false;
7
7
  const syncDeleteUsers = async () => {
8
8
  const deviceStatus = getDeviceStatus();
9
9
  if (deviceStatus.isWifiActive) {
10
10
  return;
11
11
  }
12
- const hasThread = hasCapability(ProductCommunicationType.THREAD);
13
- if (hasThread &&
14
- (deviceStatus.onlineType === "local" || deviceStatus.onlineType === "cloud")) {
12
+ if (!isUseNearChannel()) {
15
13
  return;
16
14
  }
17
- if (isSyncDone)
15
+ if (isSyncing)
18
16
  return;
19
- if (deviceStatus.type === "online" && deviceStatus.onlineType === "ble") {
20
- isSyncDone = true;
21
- let count = 0;
22
- const handleSync = async () => {
23
- try {
24
- const { removedUser = [] } = await getUsersSyncLockData(config.devInfo.devId);
25
- await Promise.all(removedUser.map((item) => deleteUser(item).catch(() => { })));
26
- isSyncDone = false;
27
- }
28
- catch (e) {
29
- if (e?.innerError?.errorCode === "DEVICE_KEY_NOT_FOUND" && count < 3) {
17
+ isSyncing = true;
18
+ let count = 0;
19
+ const handleSync = async () => {
20
+ try {
21
+ const { removedUser = [] } = await getUsersSyncLockData(config.devInfo.devId);
22
+ const deleteSerialCollectFailures = async (users) => {
23
+ const failed = [];
24
+ for (const item of users) {
25
+ try {
26
+ await deleteUser(item);
27
+ }
28
+ catch {
29
+ failed.push(item);
30
+ }
31
+ }
32
+ return failed;
33
+ };
34
+ let failed = await deleteSerialCollectFailures(removedUser);
35
+ if (failed.length > 0) {
36
+ failed = await deleteSerialCollectFailures(failed);
37
+ if (failed.length > 0 && count < 3) {
30
38
  count++;
31
39
  setTimeout(async () => {
32
40
  await handleSync();
33
41
  }, 2000);
34
42
  }
43
+ else {
44
+ isSyncing = false;
45
+ }
35
46
  }
36
- };
37
- handleSync();
38
- }
47
+ else {
48
+ isSyncing = false;
49
+ }
50
+ }
51
+ catch (e) {
52
+ if (e?.innerError?.errorCode === "DEVICE_KEY_NOT_FOUND" && count < 3) {
53
+ count++;
54
+ setTimeout(async () => {
55
+ await handleSync();
56
+ }, 2000);
57
+ }
58
+ else {
59
+ isSyncing = false;
60
+ }
61
+ }
62
+ };
63
+ handleSync();
39
64
  };
40
65
  export default syncDeleteUsers;
package/lib/temporary.js CHANGED
@@ -3,31 +3,17 @@ import config from "./config";
3
3
  import { formatWeek, isUseNearChannel, parallelOnly, parseOfflinePassword, parseWeek, validateEffectiveConfig, } from "./utils";
4
4
  import { LoopTypes } from "./utils/constant";
5
5
  import { encrypt } from "./utils/device";
6
- import { getError } from "./utils/errors";
6
+ import { getError, handleCloudError } from "./utils/errors";
7
7
  import { addTempPwd as addTempPwdDpMap, reportAddTempPwd as reportAddTempPwdDpMap, removeTempPwd as removeTempPwdDpMap, reportRemoveTempPwd as reportRemoveTempPwdDpMap, } from "./config/dp-map/unlock-method";
8
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 = (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
- }
26
- };
27
13
  const isValidPassword = async (params) => {
28
14
  const validateResult = await validateTempPwd(params);
29
15
  if (!validateResult.valid) {
30
- handleError(validateResult);
16
+ handleCloudError(validateResult);
31
17
  }
32
18
  return true;
33
19
  };
@@ -144,7 +130,7 @@ export const createTempCustom = parallelOnly(async (params) => {
144
130
  };
145
131
  }
146
132
  catch (error) {
147
- throw handleError(error?.innerError ?? error);
133
+ throw handleCloudError(error);
148
134
  }
149
135
  }
150
136
  });
@@ -186,7 +172,7 @@ export const removeTempCustom = async (params) => {
186
172
  }
187
173
  }
188
174
  catch (e) {
189
- handleError(e?.innerError ?? e);
175
+ handleCloudError(e);
190
176
  }
191
177
  };
192
178
  export const updateTempCustom = async (params) => {
@@ -220,19 +206,15 @@ export const updateTempCustom = async (params) => {
220
206
  });
221
207
  }
222
208
  catch (error) {
223
- handleError(error?.innerError ?? error);
209
+ handleCloudError(error);
224
210
  }
225
211
  };
226
212
  const getOfflinePassword = async (params) => {
227
213
  try {
228
- const res = await createOfflinePassword(params);
229
- return {
230
- ...res,
231
- pwd: parseOfflinePassword(res.pwd),
232
- };
214
+ return await createOfflinePassword(params);
233
215
  }
234
216
  catch (error) {
235
- throw handleError(error?.innerError ?? error);
217
+ throw handleCloudError(error);
236
218
  }
237
219
  };
238
220
  export const createTempLimit = async (params) => {
@@ -500,7 +482,7 @@ const changePasswordPhase = async (unlockBindingId, phase) => {
500
482
  });
501
483
  }
502
484
  catch (e) {
503
- handleError(e?.innerError ?? e);
485
+ handleCloudError(e);
504
486
  }
505
487
  return true;
506
488
  };
@@ -536,7 +518,7 @@ export const renameTemp = async (params) => {
536
518
  }
537
519
  }
538
520
  catch (e) {
539
- handleError(e);
521
+ handleCloudError(e);
540
522
  }
541
523
  };
542
524
  export const saveTempOnlineUnlimited = async (params) => {
@@ -582,7 +564,7 @@ export const saveTempOnlineUnlimited = async (params) => {
582
564
  };
583
565
  }
584
566
  catch (error) {
585
- throw handleError(error?.innerError ?? error);
567
+ throw handleCloudError(error);
586
568
  }
587
569
  };
588
570
  export const createTempOffline = async (params) => {
@@ -640,7 +622,7 @@ export const removeTempOnlineUnlimited = async (id) => {
640
622
  });
641
623
  }
642
624
  catch (error) {
643
- throw handleError(error?.innerError ?? error);
625
+ throw handleCloudError(error);
644
626
  }
645
627
  };
646
628
  const onLinePasswordStatusMap = {
@@ -674,7 +656,7 @@ export const getTempOnlineUnlimitedList = async () => {
674
656
  return newPswList;
675
657
  }
676
658
  catch (error) {
677
- throw handleError(error?.innerError ?? error);
659
+ throw handleCloudError(error);
678
660
  }
679
661
  };
680
662
  const offlinePasswordTypeMap = {
@@ -693,7 +675,7 @@ export const getTempOfflineEffectiveList = async (pwdTypeCode) => {
693
675
  return offLineValidPswList;
694
676
  }
695
677
  catch (error) {
696
- throw handleError(error?.innerError ?? error);
678
+ throw handleCloudError(error);
697
679
  }
698
680
  };
699
681
  export const getTempOfflineInvalidList = async (pwdTypeCode) => {
@@ -706,6 +688,6 @@ export const getTempOfflineInvalidList = async (pwdTypeCode) => {
706
688
  return offLineFailurePswList;
707
689
  }
708
690
  catch (error) {
709
- throw handleError(error?.innerError ?? error);
691
+ throw handleCloudError(error);
710
692
  }
711
693
  };
@@ -1,17 +1,15 @@
1
1
  import dpUtils from "@ray-js/tuya-dp-transform";
2
2
  import { bindUnlockMethodToUser, bindUnlockMethodToUserByRecord, checkFreeUnlockMethods, createUnlockMethod, removeUnlockMethod, editUnlockMethod, fetchCreatePasswordSN, fetchFreeUnlockMethods, getUnlockMethodInfo, unbindMemberUnlockMethod, } from "./api/lock";
3
- import { getUserDetail } from "./api/user";
4
3
  import config from "./config";
5
4
  import dpCodes from "./config/dp-code";
6
5
  import { add as addMap, reportAdd as reportAddMap, remove as removeMap, reportRemove as reportRemoveMap, } from "./config/dp-map/unlock-method";
7
6
  import { add as addBigMap, reportAdd as reportAddBigMap, remove as removeBigMap, reportRemove as reportRemoveBigMap, } from "./config/dp-map/unlock-method-big";
8
- import { validConfigDpMap } from "./config/dp-map/common";
9
7
  import { getPermanentSetting, getUnlockMethodTypeByDpCode, getUnlockMethodTypeByType, isAdmin, parallelOnly, sleep, } from "./utils";
10
8
  import { getError } from "./utils/errors";
11
9
  import { publishDps } from "./utils/publishDps";
12
10
  import { encrypt } from "./utils/device";
13
11
  import emitter from "./utils/event";
14
- import { DPCHANGE, UNLOCK_METHOD_EVENT } from "./utils/constant";
12
+ import { DPCHANGE, LoopTypes, UNLOCK_METHOD_EVENT } from "./utils/constant";
15
13
  import { getFileRemoteUrl, sendPhoneVerifyCode } from "./api";
16
14
  import { getUserInfo } from "./user";
17
15
  import { getDeviceAdvancedAbilities } from "./capability";
@@ -22,7 +20,10 @@ const getAddUnlockError = (status) => {
22
20
  if (status === 0xfe) {
23
21
  return getError(1026);
24
22
  }
25
- return getError(1016);
23
+ return {
24
+ ...getError(1016),
25
+ devCode: status,
26
+ };
26
27
  };
27
28
  export const getUnlockMethodDetail = async (id) => {
28
29
  const cloudData = await getUnlockMethodInfo({
@@ -58,8 +59,7 @@ const getUnlockMethodBase = async (type, userId) => {
58
59
  : dpCodes.unlockMethodCreate;
59
60
  const dpId = idsByCode[unlockMethodConfig.code];
60
61
  const [user, sn] = await Promise.all([
61
- getUserDetail({
62
- devId: devId,
62
+ getUserInfo({
63
63
  userId: userId,
64
64
  }),
65
65
  fetchCreatePasswordSN({
@@ -67,10 +67,42 @@ const getUnlockMethodBase = async (type, userId) => {
67
67
  dpId,
68
68
  }),
69
69
  ]);
70
- const { userType, lockUserId, userTimeSet } = user;
70
+ const { userType, lockUserId, timeScheduleInfo } = user;
71
71
  let validConfig;
72
- if (userTimeSet) {
73
- validConfig = dpUtils.parse(userTimeSet, validConfigDpMap.childMap);
72
+ if (timeScheduleInfo) {
73
+ const { permanent, effectiveTime, expiredTime, scheduleDetails } = timeScheduleInfo;
74
+ if (permanent) {
75
+ validConfig = {
76
+ startTime: effectiveTime
77
+ ? Math.floor(effectiveTime / 1000)
78
+ : 0x386cd300,
79
+ endTime: expiredTime ? Math.floor(expiredTime / 1000) : 0x72bc9b7f,
80
+ loop: LoopTypes.NONE,
81
+ loopConfig: 0,
82
+ weeks: [0, 0, 0, 0, 0, 0, 0],
83
+ days: [],
84
+ startHour: 0,
85
+ startMinute: 0,
86
+ endHour: 0,
87
+ endMinute: 0,
88
+ };
89
+ }
90
+ else {
91
+ validConfig = {
92
+ startTime: Math.floor((effectiveTime || +new Date()) / 1000),
93
+ endTime: expiredTime ? Math.floor(expiredTime / 1000) : 0x72bc9b7f,
94
+ loop: scheduleDetails?.repeat ? LoopTypes.WEEK : LoopTypes.NONE,
95
+ loopConfig: 0,
96
+ weeks: scheduleDetails?.repeat
97
+ ? scheduleDetails?.weeks
98
+ : [0, 0, 0, 0, 0, 0, 0],
99
+ days: [],
100
+ startHour: Math.floor((scheduleDetails?.effectiveTime ?? 0) / 60),
101
+ startMinute: (scheduleDetails?.effectiveTime ?? 0) % 60,
102
+ endHour: Math.floor((scheduleDetails?.invalidTime ?? 0) / 60),
103
+ endMinute: (scheduleDetails?.invalidTime ?? 0) % 60,
104
+ };
105
+ }
74
106
  }
75
107
  else {
76
108
  validConfig = getPermanentSetting();
@@ -311,7 +343,8 @@ const handleAddReport = async (dps) => {
311
343
  };
312
344
  }
313
345
  }
314
- catch {
346
+ catch (err) {
347
+ console.warn("AddUnlockMethod failed", err);
315
348
  eventData = {
316
349
  stage: "fail",
317
350
  type,
@@ -350,6 +383,7 @@ export const startAddUnlockMethod = async (params) => {
350
383
  const res = await publishDps({
351
384
  [addDpCode]: dpUtils.format(dpData, addDpMap),
352
385
  }, {
386
+ timeout: params.timeout,
353
387
  checkReport: (dpData) => {
354
388
  if (typeof dpData[addDpCode] !== "undefined") {
355
389
  const result = dpUtils.parse(dpData[addDpCode], addDpReportMap);
@@ -375,6 +409,7 @@ export const startAddUnlockMethod = async (params) => {
375
409
  });
376
410
  if (res.stage === 0) {
377
411
  monitoringAddReport({
412
+ timeout: params.timeout,
378
413
  unlockMethodConfig,
379
414
  total: res.total,
380
415
  dpCode: addDpCode,
@@ -446,7 +481,7 @@ export const deleteUnlockMethod = parallelOnly(async (id) => {
446
481
  admin: isAdmin(userType),
447
482
  memberId: lockUserId,
448
483
  unlockId,
449
- target: 1,
484
+ operation: 1,
450
485
  };
451
486
  const res = await publishDps({
452
487
  [removeDPCode]: dpUtils.format(dpData, (config.supportBigData ? removeBigMap : removeMap)),
package/lib/user.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EffectiveConfig, UnlockMethodBaseInfo, UserInfo } from "./interface";
1
+ import { EffectiveConfig, UserInfo } from "./interface";
2
2
  interface getUsersParams {
3
3
  page?: number;
4
4
  pageSize?: number;
@@ -11,27 +11,7 @@ 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<{
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
- }>;
14
+ export declare const getUserInfo: (params: getUserInfoParams) => Promise<UserInfo>;
35
15
  interface updateUserLimitTimeParams {
36
16
  userId: string;
37
17
  lockUserId: number;
@@ -39,12 +19,12 @@ interface updateUserLimitTimeParams {
39
19
  effective?: EffectiveConfig;
40
20
  offlineUnlock?: boolean;
41
21
  }
42
- export declare const updateUserLimitTime: (params: updateUserLimitTimeParams) => Promise<boolean>;
22
+ export declare const updateUserLimitTime: (params: updateUserLimitTimeParams) => Promise<true | undefined>;
43
23
  export declare const openAddFamilyUser: () => Promise<unknown>;
44
24
  export declare const openFamilyUserDetail: (userId: string) => Promise<undefined>;
45
25
  interface AddUserParams {
46
26
  name: string;
47
27
  }
48
- export declare const addUser: (params: AddUserParams) => Promise<import("./api/user").AddNormalUserResponse>;
28
+ export declare const addUser: (params: AddUserParams) => Promise<void>;
49
29
  export declare const removeUser: (userId: string) => Promise<void>;
50
30
  export {};
package/lib/user.js CHANGED
@@ -1,11 +1,11 @@
1
- import { getUserDetail, getUserDetailQuery, getUserList, } from "./api/user";
1
+ import { 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";
5
5
  import { publishDps } from "./utils/publishDps";
6
6
  import dpCodes from "./config/dp-code";
7
7
  import DpUtils from "@ray-js/tuya-dp-transform";
8
- import { getError } from "./utils/errors";
8
+ import { getError, handleCloudError } from "./utils/errors";
9
9
  import { updateUserTimeSchedule, addNormalUser, removeNormalUser, } from "./api/user";
10
10
  import { validConfigDpMap } from "./config/dp-map/common";
11
11
  import { formatTimestampToMilliseconds, formatWeek, getPermanentSetting, isAdmin, isUseNearChannel, parseWeek, unlockMethodConfigs, validateEffectiveConfig, } from "./utils";
@@ -118,8 +118,11 @@ export const updateUserLimitTime = async (params) => {
118
118
  if (!permanent) {
119
119
  validateEffectiveConfig(effective);
120
120
  }
121
- const { userType } = await getUserDetail({
122
- devId: config.devInfo.devId,
121
+ const currentUser = await getCurrentUser();
122
+ if (!isAdmin(currentUser.userType)) {
123
+ throw getError(1069);
124
+ }
125
+ const { userType } = await getUserInfo({
123
126
  userId,
124
127
  });
125
128
  if (isAdmin(userType)) {
@@ -156,33 +159,33 @@ export const updateUserLimitTime = async (params) => {
156
159
  endMinute: expiredTime % 60,
157
160
  },
158
161
  };
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
- }
162
+ const dpCode = config.supportBigData
163
+ ? dpCodes.unlockMethodEditW
164
+ : dpCodes.unlockMethodEdit;
165
+ const res = (await publishDps({
166
+ [dpCode]: DpUtils.format(dpValue, (config.supportBigData ? updateMapBig : updateMap)),
167
+ }, {
168
+ checkReport: (dps) => {
169
+ if (typeof dps[dpCode] !== "undefined") {
170
+ const result = DpUtils.parse(dps[dpCode], (config.supportBigData
171
+ ? reportUpdateMapBig
172
+ : reportUpdateMap));
173
+ if (result.type === 0) {
174
+ if (result.memberId === lockUserId) {
175
+ return result;
176
+ }
177
+ else {
178
+ console.warn("An incorrect member id was returned");
178
179
  }
179
180
  }
180
- return false;
181
- },
182
- }));
183
- if (res.status !== 255) {
184
- throw getError(1011);
185
- }
181
+ }
182
+ return false;
183
+ },
184
+ }));
185
+ if (res.status !== 255) {
186
+ throw getError(1011);
187
+ }
188
+ try {
186
189
  await updateUserTimeSchedule({
187
190
  devId: config.devInfo.devId,
188
191
  userId: userId,
@@ -201,11 +204,11 @@ export const updateUserLimitTime = async (params) => {
201
204
  ],
202
205
  },
203
206
  });
207
+ return true;
204
208
  }
205
209
  catch (e) {
206
- throw getError(1012);
210
+ handleCloudError(e, 1012);
207
211
  }
208
- return true;
209
212
  };
210
213
  export const openAddFamilyUser = async () => {
211
214
  const homeInfo = await getCurrentHomeInfo();
@@ -259,17 +262,24 @@ export const addUser = async (params) => {
259
262
  if (!params.name) {
260
263
  throw getError(1009, "name");
261
264
  }
262
- return addNormalUser({
263
- devId: config.devInfo.devId,
264
- name: params.name,
265
- });
265
+ try {
266
+ await addNormalUser({
267
+ devId: config.devInfo.devId,
268
+ name: params.name,
269
+ });
270
+ }
271
+ catch (e) {
272
+ if (e?.innerError?.errorCode === "DEFINITION_PARAM_NAME_REPEAT") {
273
+ throw getError(1068);
274
+ }
275
+ throw e;
276
+ }
266
277
  };
267
278
  export const removeUser = async (userId) => {
268
279
  if (!config.supportBigData) {
269
280
  throw getError(1060);
270
281
  }
271
- const res = await getUserDetail({
272
- devId: config.devInfo.devId,
282
+ const res = await getUserInfo({
273
283
  userId,
274
284
  });
275
285
  if (isUseNearChannel()) {
@@ -176,4 +176,5 @@ export declare const onAppShow: (cb: () => void) => void;
176
176
  export declare const offAppShow: (cb: () => void) => void;
177
177
  export declare const onAppHide: (cb: () => void) => void;
178
178
  export declare const offAppHide: (cb: () => void) => void;
179
+ export declare const trackEvent: (event: string, data: Record<string, any>) => void;
179
180
  export {};
@@ -364,3 +364,9 @@ export const onAppHide = (cb) => {
364
364
  export const offAppHide = (cb) => {
365
365
  ty.offAppShow(cb);
366
366
  };
367
+ export const trackEvent = (event, data) => {
368
+ ty.event({
369
+ eventId: event,
370
+ event: data,
371
+ });
372
+ };
@@ -1,2 +1,3 @@
1
1
  import { ErrorData } from "../interface";
2
2
  export declare const getError: (code: number, ...places: string[]) => ErrorData;
3
+ export declare const handleCloudError: (err: any, code?: number) => never;
@@ -65,6 +65,9 @@ const errors = {
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
67
  1066: "Phone number cannot be empty",
68
+ 1067: "Password limit reached within this period",
69
+ 1068: "There is already a member with the same name",
70
+ 1069: "No permission to modify member validity",
68
71
  };
69
72
  export const getError = (code, ...places) => {
70
73
  if (errors[code]) {
@@ -84,3 +87,36 @@ export const getError = (code, ...places) => {
84
87
  errorMsg: "unknow error",
85
88
  };
86
89
  };
90
+ export const handleCloudError = (err, code) => {
91
+ if (err?.innerError?.errorCode) {
92
+ let error;
93
+ switch (err.innerError.errorCode) {
94
+ case "USER_PWD_ALREADY_EXIST":
95
+ error = getError(1037);
96
+ break;
97
+ case "LOCK_PWD_NAME_REPEAT":
98
+ case "OFFLINE_PWD_NAME_REPEAT":
99
+ error = getError(1038);
100
+ break;
101
+ case "START_END_DATE_NOT_RIGHT":
102
+ error = getError(1039);
103
+ break;
104
+ case "RECORD_NOT_EXIST":
105
+ error = getError(1040);
106
+ break;
107
+ case "OFFLINE_PWD_EXAUST_IN_PERIOD":
108
+ error = getError(1067);
109
+ break;
110
+ default:
111
+ }
112
+ if (error) {
113
+ error.errorMsg = err.innerError.errorMsg;
114
+ error.innerError = err.innerError;
115
+ throw error;
116
+ }
117
+ }
118
+ if (code) {
119
+ throw getError(code);
120
+ }
121
+ throw err;
122
+ };
@@ -62,9 +62,8 @@ export const parseWeek = (value) => {
62
62
  .slice(0, 7);
63
63
  };
64
64
  export const getPermanentSetting = () => {
65
- const now = Math.floor(+new Date() / 1000);
66
65
  return {
67
- startTime: now,
66
+ startTime: 0x386cd300,
68
67
  endTime: 0x72bc9b7f,
69
68
  loop: LoopTypes.NONE,
70
69
  loopConfig: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.1.1-beta.9",
3
+ "version": "1.1.1",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"