@ray-js/lock-sdk 1.1.1-beta.8 → 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/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
@@ -82,26 +82,12 @@ export declare const getUserList: (params: getUserListParams) => Promise<{
82
82
  user: UserListItem[];
83
83
  hasNext: boolean;
84
84
  }>;
85
- interface GetUserDetailParams {
85
+ interface GetUserDetailQueryParams {
86
86
  devId: string;
87
87
  userId: string;
88
+ dpIds: string;
88
89
  }
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>;
90
+ export declare const getUserDetailQuery: (params: GetUserDetailQueryParams) => Promise<UserListItem>;
105
91
  export interface RemovedUserData {
106
92
  userId: string;
107
93
  lockUserId: number;
package/lib/api/user.js CHANGED
@@ -38,9 +38,9 @@ export const getUserList = (params) => {
38
38
  data: params,
39
39
  });
40
40
  };
41
- export const getUserDetail = (params) => {
41
+ export const getUserDetailQuery = (params) => {
42
42
  return requestApi({
43
- api: 'm.lock.device.member.detail',
43
+ api: "m.lock.user.detail.query",
44
44
  version: "1.0",
45
45
  data: params,
46
46
  });
@@ -48,7 +48,7 @@ export const getUserDetail = (params) => {
48
48
  export const getUsersSyncLockData = (deviceId) => {
49
49
  return requestApi({
50
50
  api: `${THING}.m.device.lock.sync.batch`,
51
- version: "2.0",
51
+ version: "1.0",
52
52
  data: {
53
53
  devId: deviceId,
54
54
  },
@@ -57,7 +57,7 @@ export const getUsersSyncLockData = (deviceId) => {
57
57
  export const removeUser = (devId, userId) => {
58
58
  return requestApi({
59
59
  api: `${THING}.m.device.member.remove`,
60
- version: "2.0",
60
+ version: "1.0",
61
61
  data: {
62
62
  devId,
63
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.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",
@@ -259,7 +260,7 @@ export const connectDevice = async () => {
259
260
  }
260
261
  }
261
262
  if (isSupportBleControl()) {
262
- if (deviceStatus.type === "online" && deviceStatus.onlineType === "ble") {
263
+ if (deviceStatus.type === "online" && deviceStatus.onlineTypes.includes("ble")) {
263
264
  return true;
264
265
  }
265
266
  return await connectBle();
@@ -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
@@ -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
  };